Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

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:
    256
    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,059
    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);