Open slalomchip opened 4 years ago
Please note that when I pasted in the code block above, I couldn't get the import lines nor the if __name__ == __main__
in the code block. Also, the underscores in if __name__ == __main__
got stripped out. Weird.
I'm not sure what the issue is. But can you try not checking get_mute
and instead unconditionally set mute to true and see if it works? Also, try setting the volume to zero and back to 1 if that doesn't work!?
I changed the toggleMute() method to ` def toggleMute(self):
self.player.set_mute(True)`
and it still did not mute.
Then I tried your suggestion to setting the volume to 0 and 1 with this code: ` def toggleMute(self):
playerVolume = self.player.get_volume()
print('Volume = ', playerVolume)
if playerVolume == 0.0:
self.player.set_volume(1.0)
print('Should now be unmuted')
else:
self.player.set_volume(0.0)
print('Should now be muted')`
and IT WORKED!
I'll just go with setting volume instead of setting mute. Thanks for the suggestion!
Also, please close the issue if you believe the issue is unique to me. Otherwise, it might be something you still want to investigate. Either way s fine with me - I have a solution. Thanks again!
I'll leave it open as it's a bug in ffpyplayer and I'll fix it at some point. But basically, https://github.com/matham/ffpyplayer/blob/master/ffpyplayer/player/core.pyx#L1543 needs to check if it's muted, but it doesn't for sdl2.
I had the same issue, on Windows10, just using ffpyplayer and opencv in a fairly basic script. Works just using the set volume thing; can save/restore the previous volume easy enough also, so not a major issue.
#class or global variable
prevVolume = 1
# in control loop
if player.get_volume() > 0:
prevVolume = player.get_volume()
player.set_volume(0)
else:
player.set_volume(prevVolume)
I wrote a script in Python 3.8 on a Windows 10 platform that uses MediaPlayer to play a video in a PyQt5 QLabel. I can toggle pause by pressing the "P" key on the keyboard but I cannot toggle mute when pressing the "M" key.
When pressing the "M" key, the
player.get_mute()
return changes fromFalse
toTrue
toFalse
just as I expect it to, but sound keeps coming out of the speaker regardless ifplayer.get_mute() == True
Here is a minimal script that exhibits this behavior.