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

Asset bundles + Video Player

Discussion in 'Asset Bundles' started by wowemotions_company, Feb 14, 2019.

  1. wowemotions_company

    wowemotions_company

    Joined:
    Jan 7, 2015
    Posts:
    8
    Hello,

    I'm using the Unity video player to play some videos on canvas and on some objects. I made a game object containing that and some other functions like displaying images, playing audios, animations and showing a web view.

    I made an assetbundle from that GO and in the other application that downloads the AB, everthing works perfect on Android, iOS and Editor except the videos.

    Doing some debbuging I realize that printing the "VideoClip.originalPath", shows the same path in both the AB creator project and the application, and this is wrong because the application is trying to open the video clip from the path of the project that creates the asset bundle. So it ends up with this error:

    Empty file: archive:/CAB-6.......c.resource
    VideoPlayer cannot play clip :.....

    I'm using Unity 2018.1.0, is this a problem that is fixed on newer Unity or there is a trick I can try with my current version? The project is a big application that everytime we try to update it to a newer version, everything blows up, so, if you know anything that can help, I would really appreciate it.

    Thank you!!
     
  2. wowemotions_company

    wowemotions_company

    Joined:
    Jan 7, 2015
    Posts:
    8
    Well I found the way and I'm leaving it here in case anyone needs it:

    My problem was that I was using public references in my code to the video clips like:

    Code (CSharp):
    1. public VideoClip video;
    Then I dragged the file into the inspector field. This creates a reference to the videoclip so it was "compiled" into the asset bundle. Finally I created a prefab with everything and made the asset bundle.

    But once the asset bundle is downloaded, the public reference to the videoclip remains poiting to the original project.

    The solution is to pack the asset bundle with all the files separated, not in a single prefab or object. In my case the prefab and the mp4 files.

    Then to reach the video we just need the mp4 file name to open it like this:

    Code (CSharp):
    1. VideoClip loadAsset = currentBundle.LoadAsset<VideoClip>(videoName);
    Pretty obvious once it is done, but I hope this helps someone that tried the first approach and failed.
     
  3. MornFall

    MornFall

    Joined:
    Jan 11, 2013
    Posts:
    160
    Hello,

    I am running into the same issue and whatever i tried always give me the error :

    Code (CSharp):
    1. WindowsVideoMedia error 0x8007007b while reading archive:/CAB-8760a846a319d4e713c613d31c75bc19/CAB-8760a846a319d4e713c613d31c75bc19.resource
    2.  
    3. Context: MFCreateFile
    4. Error details: The filename, directory name, or volume label syntax is incorrect.
    5.  
    I tried to follow your solution and created an asset bundle with just the video clip in it, but i guess i am missing a step... Unity just refuses to load the clip and use it in the videoplayer.
    Could you please give a bit more detailed for your solutions ? i am guessing it just a simple step that i am missing, but can t figure it out.
     
    kamlesh9070 and cparki77 like this.