working with mp4 files when supporting both Standalone and iOS builds

Basically I’m asking the same thing as this user posted: How to use video files twice: Once as Resources and once as StreamingAssets - Questions & Answers - Unity Discussions

I have a project which supports both Standalone PC/OSX builds as well as iOS builds. I’m using a third-party package to support rendering a movie to a texture for iOS, which has the requirement that the assets are in the StreamingAssets folder. For the Standalone build, I want to simply use a MovieTexture format, however for this to work I keep my MP4 file in the Resources folder and use Resources.Load.

I tried having a copy of my mp4 files in both places, but iOS won’t compile as it’s complaining about not supporting MovieTextures, despite the fact that I’m not referencing the files anywhere, they just sit in the Resources folder. Even if that did work, requiring two copies of each mp4 movie seems like a poor workaround. I’ve tried using the WWW class, but wasn’t having any luck with the MovieTexture format, it just wouldn’t load the video.

What’s everyone else doing to support video’s across Standalone and mobile (iOS in my case)?

It seems like the best way to handle this particular situation is to use AssetBundles.

I take the version of the mp4 file that Unity converts to a “MovieTexture” on import for PC/OSX builds, and the regular unconverted mp4 file (non MovieTexture, inside StreamingAssets folder). I create an AssetBundle containing both versions of the movie, and place that bundle in the StreamingAssets folder. This way, I can load the proper version of the mp4 file and circumvent the compile errors you normaly get for having a MovieTexture file anywhere when building for iOS.

If I wanted to keep the movie files on a server somewhere, I could simply use a WWW request to stream in the appropriate AssetBundle, eliminating the need to have two different versions of the same movie files.