PDA

View Full Version : Phonon in standalone app via py2app - backend plugin error



tory108
14th January 2009, 00:34
Hi, everybody,

I'm attempting to use phonon in a standalone app on Mac OS X.

At the moment, I am using py2app to bundle the application. When I try to play audio in the resulting app on a machine that doesn't have Qt installed, I receive the following error:

Phonon::FactoryPrivate::createBackend(void) phonon backend plugin could not be loaded

When I run the original python script locally (where I have PyQt and Qt w/ phonon installed), it performs exactly as expected. When I run the py2app-generated app locally, it plays audio as expected (the app does throw a threading error, but we'll save that one for another day).

When I run the same py2app-generated app on a different machine and then try to play an audio file, I get the above "phonon backend plugin" error.

My environment:
- python 2.6.1
- MySQLdb 1.2.2
- Qt 4.4.3
- sip 4.7.7
- PyQt 4.4.3
- py2app 0.3.6

FWIW:
All Macs involved have QuickTime 7.5.5
I create my app via python setup.py py2app --includes sip


Thank you for reading. Any advice about creating a standalone app that uses phonon would be deeply appreciated. :o

xenofanes
15th January 2009, 13:25
I had a similar problem in windows. When I moved the executable from local directory, application needs the QtCore.dll QtGui.dll phonon.dll. When these are not included, it produces error like "could not find QtCore.dll". Even I copied these dlls, phonon backend couldn't be loaded. Luckily, I found that phonon backend uses QtOpenGL4.dll. If you don't include QtOpenGL4.dll, app doesn't say that "could not find QtOpenGL4.dll". I hope including QtOpenGL4.dll (I don't know how can you do this in mac) will resolve your problem.

wheezl
16th January 2009, 01:22
Thank you for reading. Any advice about creating a standalone app that uses phonon would be deeply appreciated. :o

I am having the same issue and have yet to discover the issue. The phonon framework seems to be copied in by py2app and I put the dylib in by hand but had no success.

tory108
16th January 2009, 20:34
Here's specifically how I was able to cure my phonon backend plugin error (on Mac OS X, etc., all listed above):

In the main method of my application's script, I added a library path to include a folder named "Plugins." Thus my main method looks like this:

if __name__ == '__main__':

app = QtGui.QApplication(sys.argv)
QtGui.QApplication.addLibraryPath(QtGui.QApplicati on.applicationDirPath() + "/../Plugins")
app.setApplicationName("Music Player")
form = radioUI()
form.show()
sys.exit(app.exec_())


Then I manually copy (every time I run py2app) the phonon_backend directory into a Plugins directory in my application. There may be a better way to do this, but this is how I do it.


What this means in practice:


- Search for the "phonon_backend" directory in your Qt installation. On my machine, it was in "~/Trolltech/Qt-4.4.3/plugins/phonon_backend." This directory should contain two files:
------ libphonon_qt7_debug.dylib
------ libphonon_qt7.dylib
(I'm not sure if you need both of these -- I take both just for safety.)


- Make a folder named "Plugins" somewhere and copy the "phonon_backend" directory into it. I make the "Plugins" folder on my desktop, so the resulting directory is "~/Desktop/Plugins/phonon_backend/" and contains the two *.dylib files listed above.


- Run py2app normally (assuming it runs normally for you).

- "Show Package Contents" of the resulting application. You should see a structure like

Contents
--- Frameworks
--- info.plist
--- MacOS
--- PkgInfo
--- Resources


- Copy your "Plugins" directory into the Contents folder. The resulting structure should look like

Contents
--- Frameworks
--- info.plist
--- MacOS
--- PkgInfo
--- Plugins
--- Resources


That should do it.

Let me know if this is unclear or doesn't work for you. I was so happy to get past the backend plugin error.

Of course, now I'm on to a threading error... :o

wheezl
20th February 2009, 18:21
Yeah I have followed your instructions but the app still crashes whenever I try to use phonon. Hopefully I will have better luck eventually.

tory108
20th February 2009, 18:34
FWIW, I got around the backend-plugin error with this fix, but I still had a threading error which prevented my application from actually playing audio. After much, much trying, I eventually learned that phonon's thread used a Qt object not registered with PyQt -- and definitively I could not access the object from python to register it!

I eventually abandoned phonon, implemented everything I needed (asynchronous playback, seekSlider) using pyaudio and wave -- which are both built-in to python -- and deployed a working application.

I spent five weeks trying to deploy a working python application with phonon, and I couldn't make it happen. If you succeed, God bless you -- you're a better developer than I! :o

tory108
20th February 2009, 18:36
Also FWIW, I had to recopy that Plugins directory (described in #5) after *every time* I ran py2app. Not a great workaround, I know...