- Home /
Audio playing before scene is fully loaded
I have an intro scene with a video. The problem is that the audio starts playing before the video is fully loaded, so the entire thing is completely out of sync... Here is the part of the code that SHOULD sync the video and the audio (js):
var IntroTexture : MovieTexture;
function Start ()
{
while(!IntroTexture.isReadyToPlay)
{}
IntroTexture.Play();
gameObject.audio.Play();
}
Now, from what I can tell, the IntroTexture.isReadyToPlay turns true as soon as the scene is loaded, so the audio starts playing immediately. But the video takes a few extra seconds (random according to the load time of the scene) to start playing. Any help would be very much appreciated.
Answer by HarshadK · Dec 02, 2014 at 02:11 PM
What you need is a Coroutine.
function Start ()
{
LoadAndPlayVideo();
}
function LoadAndPlayVideo()
{
while(!IntroTexture.isReadyToPlay)
{
yield;
}
IntroTexture.Play();
gameObject.audio.Play();
}
Nope. On the first play after the install, the audio still starts seconds before the video.
Your answer
Follow this Question
Related Questions
Play VideoTexture's audio only 1 Answer
Is it possible to switch audio tracks in a video? 0 Answers
Playing Video When Clicked (Stay Paused In Scene) 0 Answers
Animated GIF and Audio Instead of Video? 3 Answers
Screenshot Movie with Audio Capture 1 Answer