Question

I am using Mac OS X. I tried using this code, taken straight from the PyQt docs:

source = Phonon.MediaSource("/Users/xxx/Desktop/audio.mp3")
player = Phonon.createPlayer(Phonon.MusicCategory, source)
media = Phonon.MediaObject(player)
media.play()

And I get no sound output.

I really just want to play a single audio file...not sure why this won't work. It was taken straight from the docs: http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/phonon-module.html#playback

Any ideas?

Was it helpful?

Solution

This works for me:

source = Phonon.MediaSource("test.ogg")
player = Phonon.createPlayer(Phonon.MusicCategory, source)
player.play()

Using a MediaObject you would do:

source = Phonon.MediaSource("test.ogg")
output = Phonon.AudioOutput(Phonon.MusicCategory)
media = Phonon.MediaObject()
media.setCurrentSource(source)
Phonon.createPath(media, output)
media.play()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top