Setting mediaPlayer.AudioMuted = true not working. Have to make SetPlaybackOptions public and call from mediaPlayer.Events.AddListener
Describe the issue Setting mediaPlayer.AudioMuted = true not working for videos opened afterwards with mediaPlayer.OpenMedia(new MediaPath(...)).
Have to make SetPlaybackOptions public in MediaPlayer.cs and call from a listener (added with mediaPlayer.Events.AddListener()) to make it work. Which is ok. But I thought it useful to report the issue, so it can be fixed, and others can work around it in the meantime.
More info:
SetPlaybackOptions() is called when opening the new media. I tested that.
Looks like something isn't loaded yet when SetPlaybackOptions() is called. I checked and the _controlInterface is not null, and set to Windows Media player. So that can't be it. Must be something internal in Windows Media Player that makes a call to SetPlaybackOptions not do its job early on.
Symptoms:
In the Editor UI the AudioMuted is ticked but audio is playing. When manually setting it, it works, but then doesn't when a new video comes on. Also tried to set the volume to 0f. Which doesn't work when set through code. It does when touched on the Edutor UI (both do). But it does not carry to the next video opened. So the above manual call once the FirstFrameReady event type is there is the only workaround for now.
Same issue exists with the PlaylistMediaPlayer. Even when both MediaPlayers have their AudioMuted set to true as well, in addition to the PlaylistMediaPlayers AudioMuted being true.
Your Setup (please complete the following information):
- Unity version: 6
- AVPro Video version (number and edition (trial/core/ultra/enterprise)): Core. Latest.
- Operating system version: Win 10
- Device model: PC
- Video specs (resolution, frame-rate, codec, file size): HD, nothing special
To Reproduce
- Create a mediaPlayer through code and set mediaPlayer.AutoMuted = true
- Open one or more videos with mediaPlayer.OpenMedia(new MediaPath(...)).
- Hear the audio, which should have been muted
Does it work if you set it in the component rather than through scripting? Have you tested it in other Unity versions, such as 2022 or 2023? afaik Unity 6 is still in preview?
If this is Windows only, then we think this has been fixed in v3.0.10. Marking as fixed and closing. Do let us know if this is not the case @wybo
Using v3.0.10 on windows, I can confirm the issue persists. After setting AudioMuted=false from script the "Muted" box is ticked in editor, but sound is audible.
Reproduced
There will be a fix for this in the next release (v3.1.1) which is due later this week.
Anyone requiring an imediate fix can make this addition into WindowsMediPlayer.cs inside the OpenMedia(...) function:
AVPro Video v3.1.1 has just been released. Please do let us know if this fixes your issue.