Search Unity

VideoPlayer EnableAudioTrack Not working.

Discussion in 'Scripting' started by Polymorphik, Aug 28, 2017.

  1. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    Hello,

    I am currently using the new VideoPlayer component. The .m4v video that I am working with has multiple audio-tracks, en, spa, fre etc.

    The documentation explicitly states that enabling/disabled audio tracks must be done when the video is not playing. My assumption is you can change it when its paused. I have a simple dropdown that gets populated on the audio-tracks a video file may contain when its finished preparing.

    When I pause the video and change the audio-track for the VideoPlayer nothing happens.

    Is this a bug? or am I overlooking something.

    Thanks.
     
  2. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    Ok figured it out, you have to Stop the video first apply your track changes then Play again. Somethings to keep in mind, Stoping will reset the VideoPlayer.time to 0, so if you do an audio-track change save the last time it was played then when VideoPlayer.prepareCompleted event gets called set VideoPlayer.time = lastPlayedTime. And it will resume where you last left off. It will do a small hiccup but so does every video player I know about.

    Thanks again Unity for this awesome Component.