Skip to main content
Known Participant
July 5, 2013
Answered

Embedded FLV

  • July 5, 2013
  • 1 reply
  • 2366 views

I have a short video of about 90 seconds that I'd like to embed in my SWF file. For some reason however my AS3 code can't find the video. I need to use the bitmapdata.draw method to take still shots of the FLV to simulate a webcam if my users don't have a webcam. I also don't want to use any components because my code takes the bitmapdata.draw from a Video class instance so I'd like to use the same methods I'm using for the webcam. I tried putting the FLV on a remote server and that worked except the bitmapdata.draw kept coming up with security violations that appear to be a bug. I'd rather have the FLV embedded anyway since its so short in length and not on a timeline so I can access it directly in Action Script.

I imported the FLV file and in the library I see the FLV with it's auto-generated MovieClip. In the output I get: Net Stat: NetStream.Play.StreamNotFound

All of the forums that I've researched talk about the FLV and the FLV Component Players, but none get this simple except Lee Brimelow's site. Hopefully it's a simple fix.

import flash.display.Sprite;

import flash.events.NetStatusEvent;

import flash.events.SecurityErrorEvent;

import flash.media.Video;

import flash.net.NetConnection;

import flash.net.NetStream;

import flash.events.Event;

var my_video:Video = new Video(720,1080);     //The video is taller than wider

addChild(my_video);

var nc:NetConnection = new NetConnection();

nc.connect(null);

var ns:NetStream = new NetStream(nc);

my_video.attachNetStream(ns);

//ns.play("http://www.postureviewer.com/video4a"); //This works and the video is still at this location.

//ns.play("Video4a.flv"); //Doesn't work

ns.play("video4a");     //Doesn't work

var netClient:Object = new Object();

netClient.onMetaData = function(meta:Object)

{

        trace("Meta Duration: "+meta.duration);

};

ns.client = netClient;

ns.addEventListener(NetStatusEvent.NET_STATUS, netstat);

function netstat(stats:NetStatusEvent)

{

        trace("Net Stat: "+stats.info.code);

};

This topic has been closed for replies.
Correct answer kglad

Are you saying that the code written above will work correctly if I package the flv locally? I'll have to reference the flv differently using File.applicationDirectory.But other than that I'm good to go right?


you don't need to even do that if you put the flv in the same directory with your published swf.  just use,

ns.play("Video4a.flv");

1 reply

kglad
Community Expert
Community Expert
July 5, 2013

put the flv on the same server as your flash app and use a local path to the flv.

Known Participant
July 5, 2013

I'm actually writing an Adobe Air App and I'm trying to avoid having the flv on the server. I wrote this small fla producing a swf to figure out this problem.

I imported the video into my fla file. Why can't my code see it?

kglad
Community Expert
Community Expert
July 5, 2013

your code can access an flv embedded in a timeline.  to do that conveniently, create a new movieclip and add the flv to that movieclip's timeline.  ie, don't use the main timeline for your embedded flv.

also, consider that you may have problems like decreased fidelity and audio/video asynchrony.

you can then use the full range of movieclip methods and properties to control your video.  but, that will be different than you're currently trying to do.  in particular, whatever you're using for a screenshot will have to change.

but, if you're creating an air app, why aren't you including your flv locally (packaged with your app)?