Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Video Some ogv files work, and some don't

Discussion in 'Audio & Video' started by Edreyn, Aug 29, 2018.

  1. Edreyn

    Edreyn

    Joined:
    Jul 5, 2017
    Posts:
    16
    Hello, everyone,
    I have a quite weird problem with my video files.
    Only some of them work when I am trying to run them in my game. As far as I understand, the problem isn't with scripts, or GameObjects, but with "wrong" files in Assets.

    The only difference I found between files, that the picture of a working file in Assets has a picture of the first frame, and those that don't work have empty frame, but with some color.

    bug.png




    Any suggestions what can be the reason, and how to fix it?
     
    Last edited: Aug 29, 2018
  2. Edreyn

    Edreyn

    Joined:
    Jul 5, 2017
    Posts:
    16
    I'll post code too, just in case.

    Code (CSharp):
    1. void PlayVideo(string thisName)
    2. {      
    3.     GameObject thisVideo = new GameObject();
    4.     GameObject areaVideo = new GameObject();
    5.  
    6.     foreach (GameObject thisObject in LargeAreas)
    7.     {
    8.         if (thisObject.name == "areaVideo")
    9.             areaVideo = thisObject;
    10.     }
    11.  
    12.     foreach (Transform thisObject in areaVideo.transform)
    13.     {
    14.         if (thisObject.name == thisName)
    15.             thisVideo = thisObject.gameObject;
    16.     }
    17.  
    18.     Debug.Log(thisVideo.name);
    19.     thisVideo.SetActive(true);
    20.  
    21.     VideoPlayer x = thisVideo.GetComponent<VideoPlayer>();
    22.     x.Play();
    23. }