- Home /
Question by
martipello · Sep 27, 2017 at 03:49 PM ·
audiovideosource
why is the audio not playing on my video player?
ok ive never used the video player before managed to get it running on android and the editor but the audio will not play, im getting the video from a url and pointing the video player towards an audio source attached to the same object as the video player component is attached, ive followed advice from this link https://stackoverflow.com/questions/41144054/using-new-unity-videoplayer-and-videoclip-api-to-play-video but havent had any joy yet below is the order of how im calling it as mentioned it works but the audio doesnt, can anyone help
private AudioSource audio;
private VideoPlayer screen;
screen = go.GetComponentInChildren<VideoPlayer>();
audio = go.GetComponentInChildren<AudioSource>();
audio.playOnAwake = false;
screen.source = VideoSource.Url;
screen.url = videoObj.VideoURL;
screen.audioOutputMode = VideoAudioOutputMode.AudioSource;
screen.EnableAudioTrack (0,true);
screen.SetTargetAudioSource (0,audio);
screen.Prepare ();
screen.Play();
audio.Play ();
Comment
Answer by GoingS · Jan 23, 2020 at 10:14 PM
The whole problem for me was Play On Awake being on. Once I unchecked it, both output modes worked for me (Audio Source and Direct).