Playing Videos in a Flash build 4.2.2

I’ve been hunting around this past week for a good method to do this, and haven’t been able to come up with a working solution (please keep in mind I’m a bit of a Unity-novice). We’re using Unity 4.2.2 and exporting to Flash Player 11.4

It is my understanding that movie textures (or anything similar) will not be supported for flash builds anytime soon. My current workaround was to rip the frames from the videos and swap out the texture on a rectangle to simulate the video playing.
(I realize how ugly this solution is, and would much appreciate any pointers toward a cleaner one.)

This ‘player’ works very nicely in the editor, the videos load and play perfectly. However, when exported to a .swf nothing shows up. There are no build errors, and the app works perfectly normally until it’s time to show a video. Then I just get a blank rectangle where the video should be. I’m pretty much at a loss for anything that could be going wrong.

Here’s a bit of the code I’m using to swap out the textures:

private ArrayList frames = new ArrayList();

for(int i = 1; i < TotalFrames; i ++)
{

WWW url = new WWW(ImagePath+i+".jpg");
yield return url;
		
frames.Add(url.texture);

}

void OnGUI()
{

    GUI.Box(videoRect, (Texture2D)frames[curFrame]);

}

2 Answers

2

Rip the frames and try this

http://wiki.unity3d.com/index.php?title=Texture_swap_animator

It’s quite versatile.

The animator does exactly what I'm doing already. I switched mine from using a gui box to a regular cube, just to be sure, but it still doesn't show when exported to a swf.

So try Erics TSA ;) just to be sure

Plugged it in to my update method. It works fine in the editor, still nothing on export.

Resolved:

I was trying to use relative paths to access the textures via WWW when instead I should have been using Resources.Load()
The compiled swf simply couldn’t find the images.

Hi Bunny, thanks for the input, I have updated the post with new additions, honestly it was something I just used until I found the FBX exporter, but you're correct and I thought It might be a good learning experience for me and others that visit this post in the future.