0

I have a unity project where i load multiple ogv-videos from a folder on my disk. When i run the game in debug mode it works perfectly, but when I build the game the video doesn't load

public class Video
{
    public MovieTexture movieTexture { get; set; }
    public string title { get; set; }

}

public class VideoLoader : MonoBehaviour {

public static List<Video> allVideos; 



// Use this for initialization
void Start () {

    StartCoroutine(LoadAllVideos());
}


IEnumerator LoadAllVideos()
{
    allVideos = new List<Video>();

    string path = "C:/Users/Bram Sikkens/Desktop/SealifeBestanden/ProductBestanden";
    string[] videoFilePaths = Directory.GetFiles(path, "*.ogv");
    for(int i =0; i< videoFilePaths.Length;i++)
    {
        WWW diskMovieDir = new WWW("file://" + videoFilePaths[i]);

        while(!diskMovieDir.isDone)
        {
            yield return null;
        }

        Video v = new Video();
        v.movieTexture = diskMovieDir.GetMovieTexture();
        v.title = videoFilePaths[i];

        allVideos.Add(v);
    }

    foreach (GameObject menu in ProductContainers.menuGameObjects)
    {

        foreach(Video video in allVideos)
        {
            if(video.title.Contains(menu.name))
            {
                menu.transform.GetChild(2).GetComponent<Renderer>().material.mainTexture = video.movieTexture;
                video.movieTexture.Play();
                video.movieTexture.loop = true;
            }
        } 
    }

}

}

What is the reason that he video doens't run when I build?

  • Sounds like a codec issue. By the way, It looks like you are trying to load all the videos in that folder and play them at all the-same time Not a good idea. You should not be using MovieTexture Unity's VideoPlayer is the new API used to play videos. – Programmer Mar 14 '18 at 07:58
  • @Programmer Hi! Thanx I'm gonna try to improve it with the videoPlayer. Could this also solve the codec issue? What do you really mean by a codec issue and how could I solve this in this situation? – Bram Sikkens Mar 14 '18 at 15:02
  • On some\ systems, `MovieTexture` can't load videos. Forget about it. – Programmer Mar 14 '18 at 18:31

0 Answers0