Search Unity

Video how to mute video while playing

Discussion in 'Audio & Video' started by eomerb, Apr 2, 2020.

  1. eomerb

    eomerb

    Joined:
    Mar 6, 2020
    Posts:
    31
    hello
    I working on a video player and wanted put a mute button
    my videoplayer code is

    frameVideoPlayer.sendFrameReadyEvents = true;
    frameVideoPlayer.frameReady += VideoPlayer_frameReady;
    frameVideoPlayer.prepareCompleted += VideoPlayer_prepareCompleted;
    frameVideoPlayer.url = videoSrc;
    frameVideoPlayer.Prepare();

    its playing in VideoPlayer_prepareCompleted method
    I add a toggle to my canvas to switch between mute and unmute
    I tried to use frameVideoPlayer.audioOutputMode = VideoAudioOutputMode.None; and VideoAudioOutputMode.Direct but not effecting while playing
    how can I change to mute and unmute while playing
    thanks
     
  2. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Hi!

    Muting the audio from a playing movie depends on how the audio signal is being output, which is controlled via VideoPlayer.audioOutputMode: https://docs.unity3d.com/ScriptReference/Video.VideoPlayer-audioOutputMode.html
    Changing the audio output mode like you are doing is only effective before the Prepare is invoked; any change done while playback is ongoing will be disregarded and only take effect on the next playback.

    Hope this helps!

    Dominique Leroux
    A/V developer at Unity
     
  3. eomerb

    eomerb

    Joined:
    Mar 6, 2020
    Posts:
    31
    azporispo likes this.
  4. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,085
    Curious why the trackindex is not a regular integer?

    Would this work? vp is an instance of VideoPlayer

    for(int i=0;i<vp.length;i++)
    vp.SetDirectAudioMute((ushort)i,f);