ok ive never used the video player in unity 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 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 video 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 ();
EDIT
as per the one below comment I'm adding some info and clarifying some points, so the unity version is 2017 the audio doesnt play in the editor or on any devices but the video works fine in the editor and on devices, here is a url I'm trying https://storage.googleapis.com/godapp-a3e4b.appspot.com/jacopatrolmontage.mp4 and here is the full code, or the method I'm using please dont pull apart other stuff I'm probably doing wrong as i am rather new to unity and C#
public void showPlayer(VideoObjects videoObj)
{
if (GameObject.Find("videoPlaner(Clone)") == null)
{
//may need scene.isValid
GameObject go = Instantiate(videoPlayer);
go.transform.SetParent(canvas.transform, false);
screen = go.GetComponentInChildren<VideoPlayer>();
audio = go.GetComponentInChildren<AudioSource>();
//audio = go.AddComponent<AudioSource>();
fsscreenBool = true;
screenSize = go.GetComponent<Transform> ().localScale;
screenPosition = go.GetComponent<Transform> ().localPosition;
canvasRectTransformScale = go.GetComponentInParent<RectTransform>
();
foreach (Transform tr in go.transform)
{
if (tr.gameObject.tag == "play")
{
Button play = tr.GetComponent<Button>();
AddPlayListener(play, screen);
preparePlayer(play,screen.isPlaying);
}
if (tr.gameObject.tag == "fullscreen")
{
Button fullScreen = tr.GetComponent<Button>();
AddFSListener(fullScreen, go);
}
if (tr.gameObject.tag == "forward")
{
}
if (tr.gameObject.tag == "rewind")
{
}
if (tr.gameObject.tag == "vidtitle")
{
tr.GetComponent<Text>().text = videoObj.VideoTitle;
}
if (tr.gameObject.tag == "loading")
{
loading = tr.gameObject;
}
}
}
else{
//print("it exists");
GameObject existingGO = GameObject.Find("videoPlaner(Clone)");
screen = existingGO.GetComponentInChildren<VideoPlayer>();
loading.SetActive (true);
foreach (Transform tr in existingGO.transform)
{
if (tr.gameObject.tag == "play")
{
}
if (tr.gameObject.tag == "fullscreen")
{
checkScreen (existingGO);
}
if (tr.gameObject.tag == "forward")
{
}
if (tr.gameObject.tag == "rewind")
{
}
if (tr.gameObject.tag == "vidtitle")
{
tr.GetComponent<Text>().text = videoObj.VideoTitle;
}
if (tr.gameObject.tag == "loading")
{
}
}
}
screen.source = VideoSource.Url;
screen.url = videoObj.VideoURL;
screen.audioOutputMode = VideoAudioOutputMode.AudioSource;
screen.EnableAudioTrack (0,true);
screen.SetTargetAudioSource (0,audio);
screen.Prepare ();
audio.Play ();
screen.Play();
}