[PyQt] phonon audio volume setting problem
Stephen Gava
elguavas at gmail.com
Fri Mar 30 05:06:15 BST 2012
hi there.
i'm using phonon to play some sounds but i can't seem to control the
audio output volume as i expect to be able to.
i set up phonon like so:
self.sfx_output=Phonon.AudioOutput(Phonon.MusicCategory,self)
self.sfx_player=Phonon.MediaObject(self)
Phonon.createPath(self.sfx_player,self.sfx_output)
and play the sounde source like so:
self.sfx_player.setCurrentSource(sound_source)
self.sfx_player.play()
this works fine, but always plays at the audio outputs full volume of
1.0 (100%).
if do self.sfx_output.setVolume(0.5), for instance, in my code, then
self.sfx_output.volume() returns 0.5 as i would expect.
if i then play a sound (as above) it play at full volume still as though
i didn't set the volume.
to try to debug i attached a function to the audio output's
'volumeChanged' signal like so:
self.sfx_output.volumeChanged.connect(self.volume_changed)
(the function merely prints the changed volume) and what i find is,
after setting the volume to what i want, and checking it, as above, as
soon as i play any sound the volumeChanged signal is emitted and the
volume is now reported as 1.0 again.
in other words calling self.sfx_player.play() causes self.sfx_output 's
volume to be reset to 1.0.
how can i make volume changes to the audio output actually work so that
playing a sound doesn't not reset the output to full volume??
thanks,
stephen.
More information about the PyQt
mailing list