views:

44

answers:

2

I've got this 1 minute long movie that I want to compile into an AS3 project. The movie started out in MOV format, so I used FFMpeg to convert it to FLV, then again with FFMpeg from FLV to SWF.

I'm embedding this movie into the AS3 binary by using Embed metadata:

[Embed(source="1.swf")]
private var _Vid:Class;

I've got a container Sprite that this movie gets added to. Before it's added in, I cast the embedded movie as a MovieClip:

var vid:Object = new _Vid();
return vid as MovieClip;

When I add the resulting movie clip to the stage, it begins playing immediately and seems to play fine. However, when I check the totalFrames property of the movie clip, it returns 0. And the movie clip doesn't seem to respond to calls to stop or gotoAndStop.

I get this same behavior from embedding the movie into an SWF in the Flash IDE then embedding the result in the same manner, so it seems something is out of whack with the way I'm adding it to the stage. Any thoughts?

EDIT: As a requirement of the product, the as3 movie cannot load the video from an external file. It must be compiled in, so the resultant .swf that does the playing can operate completely on its own without having to rely on other external files.

EDIT 2: Upon further inspection, the MovieClip instance that results from:

[Embed(source="1.swf")]
private var _Vid:Class;
var vid:Object = new _Vid();
return vid as MovieClip;

has one child object which is of class Loader, and that child has no children. I tried casting the child directly as MovieClip but to no avail.

EDIT 3: From what I'm reading here and here, the 10.1 api for the NetStream object exposes a method called appendBytes. I still need to look further into this, but I could embed the .flv file as an octet stream and feed the bytes manually to the Net Stream object to play the video. I'll post the result of my tests in a few...

+1  A: 

Check these tutorials

http://gotoandlearn.com/play.php?id=46

http://gotoandlearn.com/play.php?id=129

I think that if the video is embed in a MovieClip as you did it , the only behavior you can expect is what you're getting at the moment. It will play but you won't have any control over it.

Why do you insist on embedding it? It will make your file bigger and the video won't play until the swf has completely loaded. It's a short video but it still will take far longer than accessing it via progressive download.

Admittedly the second tutorial doesn't have much relevance but why not add it , it gives you more scope on how to deal with media in Flash. OSMF is a new framework and I think it makes sense to know about it.

PatrickS
Neither of these tutorials talk about embedding a video file, which I plainly included in my question. This is a requirement of the product...the video cannot be downloaded from a network location.
jtrim
i find you a bit quick on the minus front. it seems that you haven't even bothered to look at the first tutorial where Lee Brimelow clearly states from the start that the video he is using is on his desktop, not a network location!!! Now if you don't understand a tutorial , blame yourself not me. Luckily , most people here are not like you! don't vent your frustration on those trying to help you. just try and learn like we all did here. my advice , relax , step back and watch the tutorial one more time, when you finally get it , just get rid of this minus and mark your question as answered.
PatrickS
Actually, I did bother to look at both tutorials in detail. The author of the first video does say the word "embedded" in the video, but it's not embedded in the sense that the video file is actually compiled into the resulting .swf file. Notice the [Embed] metadata tag in my original question. Your answer was completely irrelevant - hence the -1. Nothing personal, your answer is just irrelevant to my question.
jtrim
You're reading too much into my -1 and comment. You take both of those as an effect of my frustration with the problem, which is a big assumption on your part. I'm simply using Stack Overflow as it was intended. Voting down irrelevant answers is part of what makes this website a really great resource. It filters out things that don't accurately answer the questions asked.
jtrim
You're absolutely right, let's use StackOverflow as intended and let others decide if the answer was irrelevant or not, but please read your question again, you describe what you do , not what you require. Where did you state that embedding the video with the [Embed] metatag was a prerequisite? I provided you with two ways to deal with video, trying to give you a different scope on how to tackle this issue. What's the reasoning behind embedding the video in a MovieClip to be added to another MovieClip? How do you intend to control playback of the movie? It just doesn't make any sense?
PatrickS
Fair enough. I'll retract my -1. It's not that big of a deal to me, but it seems to be a huge deal to you for some reason. I can't retract it unless you edit your answer though.It's not possible to embed a .flv movie with [Embed] metadata and end up with anything but a ByteArray, so the only other way to embed a movie is to first convert it to swf, then embed it as a MovieClip. I'm not adding the embedded video to an existing MovieClip, that's what embedded swf's are coerced into.
jtrim
As for playback control, MovieClip instances respond to stop, play, and gotoAndStop, so that's how I intended to control the playback of the video. The end result doesn't require fine-grained seeking, just basic play/pause functionality. I assumed that, since the movie swf is being embedded as a MovieClip, it would respond to stop() and play() and behave accordingly, but that's not the result Im' getting.
jtrim
The resultant flash will not be downloaded via a web server, it's going to be distributed on a disc. The video asset itself is sensitive material, so we're trying to make it as difficult as possible for people to get their hands directly on the video.
jtrim
Thanks for the clarification (and removing the minus)! I would recommend you to ask a new question about protecting video content and possible encryption method when delivering media on disc.
PatrickS
A: 

I ended up embedding the video as binary data:

[Embed(source="1004.flv", mimeType="application/octet-stream")]

Then using NetStream.appendBytes() to feed the video to a NetStream that's hooked up to a Video object. This works beautifully, and the NetStream can be paused and replayed.

jtrim