- Home /
 
               Question by 
               MikaNishida · Nov 12, 2018 at 03:04 PM · 
                soundvideofadeoutfadein  
              
 
              Stop BGM while movie is playing.
I want to stop BGM while playing movies. If possible, I want to fade out BGM when the movie starts, and I want to fade in BGM when the movie is over, what should I add in the following code? Thanks in advance.
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 using UnityEngine.Video;
 
 [RequireComponent(typeof(VideoPlayer), typeof(AudioSource))]
 public class VideoPlayerManager : MonoBehaviour {
 
     VideoPlayer player;
 
     public AudioSource bgm;
 
     private void Awake()
     {
         // get components
         player = GetComponent<VideoPlayer>();
         AudioSource audioSource = GetComponent<AudioSource>();
 
         //  audio setting
         player.audioOutputMode = VideoAudioOutputMode.AudioSource;
         player.EnableAudioTrack(0, true);
         player.SetTargetAudioSource(0, audioSource);
     }
 
 
    
     // call this method from other class when the gesture is detected.
     public void OperateVideo()
     {
         Debug.Log("VideoPlayerOnGui was called.");
 
         //  play the movie if the movie is not playing.
         if (!player.isPlaying)
         {
             
             //  play movie
             player.Play();
         }
         else
         {
             // return if the movie is playing.
             return;
         }
     }
 }
 
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Making Enemy Audio quieter 1 Answer
Audio Fade Trigger Script - Coroutine Bug 1 Answer
AudioClip.Create fade in and out 1 Answer
FadeIn and FadeOut Itween 0 Answers
SceneFader 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                