views:

48

answers:

1

Hello,

I'm trying to control the video playback of a live video stream using ActionScript 3 code in Flash Professional.

There's a FLVPlayback component on my stage titled "flvPlayer", and in Frame one of my "Actions" layer, I have the following code:

import fl.video.FLVPlayback; 
import flash.display.Sprite;
var vidURL:String = new String("rtmp://www.mycompanyserver.com/test/live/livestream");
var flvPlayer:FLVPlayback = new FLVPlayback(); 
addChild(flvPlayer);  
flvPlayer.source = vidURL;
flvPlayer.isLive = true;
flvPlayer.autoPlay = true;

However, the video doesn't play.

This is what appears in the Output log:

http://i.imgur.com/J5n7J.png

I can get it to work by adding the source to the Compenent Parameters window, but I need to be able to access those parameters in code.

Thanks in advance.

A: 

First off you need to EITHER

-1- import fl.video.FLVPlayback and create a new instance like you did var flvPlayer:FLVPlayback = new FLVPlayback();

OR

-2- drag the FLVPlayback component and name the instance with the properties pane and then reference it directly in your actionscript

So if you're not even seeing your player it's probably because you're doing both. Since you want to control this programmatically go with option -1-. You still need your FLVPlayback component in your Library, however.


Second, you should change the order in which you set your variables. Once autoplay is set then the player will automatically play once source is set so set your source last.

import fl.video.FLVPlayback; 
var flvPlayer:FLVPlayback = new FLVPlayback(); 
addChild(flvPlayer);
flvPlayer.isLive = true;
flvPlayer.autoPlay = true;
flvPlayer.source = "rtmp://www.mycompanyserver.com/test/live/livestream";



Finally, your unhandled NetStatusEvent appears to be coming from a problem with your RTMP connection not the player itself. Make sure you don't have any security sandbox violations and go from there.

Brandon Cook