Load VideoClip in assetbundle on Android

Thanks for the reply, i didn’t see it until today.

My asset bundles were just lists video clips, I was downloading them, populating them in a dictionary, then unloading the bundle. I tried with both compressed and uncompressed bundles, and each time got the same error, “Video clip could not be read”. But even if it worked uncompressed(which it doesn’t) i wonder why it doesn’t work compressed? Some of the video clips are very large, 200mb, and i can compress them down to 10-20mb.

So, as per that forum post, it’s a better idea to add the video clip class instead of a list in a script?

the key is in how you load the bundles. can you post your code?

Oh geez, my code is gone now lol. Basically I was just writing it to disc with File.WriteAllBytes, and the loading it with AssetBundle.LoadFromFile, taking the video off and putting it in a list, then unloading the bundle.

I am pretty sure I had tried this solution for the “VideoClip class got stripped” part (which is an absurd anomaly in itself as it was clearly referenced at multiple instances in the project) which did not work. But I see some newer lines in that solution which I may have to try someday.

Also @Mashimaro7 I had to devise some new methods as the ‘TextAsset’ method was crashing the app due to memory usage cap. Specifically, I had used a zip file chunk loading solution. Unity seems to have a knack for making us devs go crazy over puny stuff. Also, I’ve not updated myself, but it seems this particular bug has been carried forward into Addressables too! Cheers!

So what do you experience, do you get an error in the log?

Unity strips classes that are not referenced anywhere when building. If your videoclips are not referenced anywhere (other than in assetbundles / assets loaded from assetbundles) it will strip the class. The link.xml allows you to explicitly include namespaces and classes, regardless of whether they’re used.

This is kind of silly to push onto us to fix.

Could the video player not be smart enough to query android SDK version and extract the video to a file on disk and stream that instead? Why not hide this implementation detail from us.

I added some logic to wait for the video to start playing before proceeding to the next screen, and unintentionally bricked all android 8 and bellow devices because of this issue.

It’s a trap waiting for every developer using addressables/asset bundles who missed the warning on the documentation. And every developer will have to write their own workaround.

1 Like

Sometimes I regret getting into this path and think web/full-stack dev would have been so smooth for me with all the stable/ample support, just because of the amount of trauma Unity has given me :face_with_spiral_eyes::roll_eyes:

2 Likes

still it’s not working in unity 2022.3.12f1.

1 Like

There’s the [Preserve] Attribute too https://docs.unity3d.com/ScriptReference/Scripting.PreserveAttribute.html

Subject: Video Playback from Uncompressed Asset Bundle Works in Mono but Fails in IL2CPP on Android 14

Hi everyone,

I’m encountering an issue where video playback works perfectly when using Mono but fails when switching to IL2CPP. I’ve tried everything discussed in similar threads, including:

  • Disabling code stripping using a custom link.xml.
  • Ensuring that the AssetBundle is uncompressed by using:

Copy code

BuildPipeline.BuildAssetBundles("Assets/StreamingAssets", BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.Android);
  • Using the latest Unity version (2022.2.19f1 LTS) and testing on Android 14.

Despite these efforts, the video still won’t play in IL2CPP, while it works fine in Mono. Has anyone faced a similar issue or found a solution for this? Any help would be appreciated!

Thanks in advance!