I am struggling to get the sounds out the video from Unity Video Player.
The video is playing fine but the sound is not working.
Here is the code I use based on this thread.
public VideoClip VideoClip;
private AudioSource audioSource;
private IEnumerator videoCoRoutine;
void Awake()
{
VideoPlayer videoPlayer = gameObject.AddComponent<VideoPlayer>();
audioSource = gameObject.AddComponent<AudioSource>();
videoPlayer.clip = VideoClip;
videoPlayer.source = VideoSource.VideoClip;
//videoPlayer.Prepare();
videoPlayer.renderMode = VideoRenderMode.CameraNearPlane;
videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
videoPlayer.EnableAudioTrack(0, true);
videoPlayer.SetTargetAudioSource(0, audioSource);
videoPlayer.Play();
audioSource.Play();
//StartCoroutine(PlayVid());
ContinueBtn.onClick.AddListener(OnContinue);
}
Can anyone kindly help ?
Thanks