Play mp3 using Python, PyQt, and Phonon

匆匆过客 提交于 2019-12-03 00:29:57
David Boddie

Phonon supports different audio file formats on different platforms, using the system's own support for media formats, so it could be that your system doesn't provide libraries for playing MP3 files. Certainly, MP3 is not supported out of the box on some Linux distributions. If you are using Linux, please take a look at the following page for information about enabling MP3 support:

http://doc.qt.io/qt-4.8/phonon-overview.html#linux

Another way to diagnose problems with Phonon's media formats is to run the Capabilities example provided with Qt:

http://doc.qt.io/qt-4.8///qt-phonon-capabilities-example.html

This should tell you which media formats are supported by your system.

In delayedInit method; create MediaObject like following:

def delayedInit(self):
    if not self.m_media:
       self.m_media = Phonon.createPlayer(Phonon.MusicCategory)

If Phonon is not outputting audio or video, but not throwing any errors. You might just have to sudo apt-get install phonon-backend-gstreamer and also maybe sudo apt-get install libphonon-dev

Phonon uses a backend of gstreamer or vlc silently, so when its not there, no errors but no functionality either. after running those commands I was able to hear sound from phonon on my raspberry pi

Hopefully this will help someone in the future.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!