Question by
Delidragon · Mar 05, 2018 at 02:32 PM ·
scripting problemvrvideo
Videoplayerprepare Problem
I do an Android-Vrgame and wanna play a video but my Audiosource starts before my first frame is loaded because play on awake is enabled. If i disable it i must start the audio via script and there is my Problem it won`t work here my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
using UnityEngine.Playables;
public class startthevideomyprecious : MonoBehaviour {
public bool isPrepared;
private VideoPlayer videoPlayer;
private AudioSource audioPlayer;
// Use this for initialization
void Start () {
videoPlayer = GetComponent<VideoPlayer> ();
audioPlayer = GetComponent<AudioSource> ();
}
// Update is called once per frame
public void starttheenginegadget () {
if (VideoPlayer.prepareCompleted) {
videoPlayer.Play ();
audioPlayer.Play ();
}
}
}
Comment
Your answer