- Home /
Audio from Video starts stuttering + video playback lag after a few minutes
Hi everyone,
I have a project with 15 videos that are set to loop and that I play one by one - by changing a material's main texture.
All seems to work fine on my MacBook Pro but I have to deploy it on a windows machine and after some time on playback I constantly start getting audio stutter and begin to lose frame rate.
This is the code I use for playback. This code is present one each of the 15 GameObjects on the scene that are triggered by an AR marker (all good on that front) and whose active state is set to true whenever the said marker is shown.
I cannot replicate this bug on my editor so I'm a bit clueless where to look at.
Thanks in advance for your time.
using UnityEngine;
using System.Collections;
public class PlayMovie : MonoBehaviour {
public MovieTexture movieToPlay;
private Renderer planeRenderer;
public AudioClip clipToPlay;
public AudioSource audioSource;
private int count = 0;
public bool hasPlayed = false;
public Director director;
void Start(){
Cursor.visible = false;
audioSource.loop = true;
movieToPlay.loop = true;
}
void OnEnable(){
count++;
planeRenderer = GameObject.FindWithTag("Plane").GetComponent<Renderer>();
if(count > 1){
director.lostTracker = false;
director.sleeping = false;
if(director.activePage == gameObject.transform.parent.gameObject.name &&
movieToPlay.isPlaying){
Debug.Log("Still Playing - not Changing");
}
else{
//Tried unloading form memory but with no success
//Resources.UnloadUnusedAssets();
movieToPlay.Stop();
audioSource.Stop();
audioSource.clip = clipToPlay;
audioSource.Play();
planeRenderer.material.mainTexture = movieToPlay;
movieToPlay.Play();
hasPlayed = true;
director.activePage = gameObject.transform.parent.gameObject.name;
director.pagePlaying = gameObject;
}
}
}
void OnDisable(){
director.lostTracker = true;
}
}
Your answer
Follow this Question
Related Questions
[NoBraves] Sound makes lag 1 Answer
Lag of video loading 1 Answer
Get Ogg Video Information 0 Answers
AudioSource.Play lags. 2 Answers