PDA

View Full Version : video class breaking


bcbirk100
01-04-2008, 11:57 PM
ok, so I created a video player in as3, and it works fine if i'm using null as my rtmp_host. but if i try to connect to my streaming server, it breaks, and acts as if it didn't load the class.
here's my code

public function VClass(target:MovieClip, rtmp_host:String, flv_name:String) {
//trace("VClass instantiated");
_video = new Video(550, 412);
_playbackTime = new TextField();

_playbackTime.y = 419;
_playbackTime.x = 425;
newFormat.font = "Verdana";
_playbackTime.embedFonts;
_playbackTime.text = "Loading";
_playbackTime.textColor = 0xFFFFFF;
_playbackTime.setTextFormat(newFormat);

_playbackTime.autoSize = TextFieldAutoSize.LEFT;

errorTxt = new TextField();
errorTxt.textColor = 0x00FF00;
errorTxt.x = 425;
errorTxt.y = 405;
errorTxt.autoSize = TextFieldAutoSize.LEFT;
errorTxt.text = "connecting...";
_duration = 0;
var connection:NetConnection = new NetConnection();
connection.addEventListener(SecurityErrorEvent.SEC URITY_ERROR, securityErrorHandler);
connection.addEventListener(NetStatusEvent.NET_STA TUS, netStatusHandler);
errorTxt.text = rtmp_host;
connection.connect(rtmp_host);
_stream = new NetStream(connection);
_stream.addEventListener(NetStatusEvent.NET_STATUS , netStatusHandler);
_stream.play(flv_name);
var client:Object = new Object();
client.onMetaData = onMetaData;
_stream.client = client;
_video.attachNetStream(_stream);
_video.smoothing = true;
target.addChild(_video);
target.addChild(_playbackTime);
target.addChild(errorTxt);
target.addEventListener(Event.ENTER_FRAME, onEnterFrame);
_scrubber = new VideoScrubber(target, _stream);


}// end of function


if i use it like this:
var vClass:VClass = new VClass(this, null, "test.flv");

it works fine, however when i change null and the flv name it breaks and it won't even show my textfields to show my error messages.

var vClass:VClass = new VClass(this, "rtmp://[myserver]/test", "test");

anybody see any errors in my script, or know why it would work with null but not with the rtmp server?
Thanks for the help.

panel
01-05-2008, 09:31 AM
Try to add this

import flash.net.ObjectEncoding;

//this setting is for playing FMS 2 Sreaming in AS3 application
NetConnection.defaultObjectEncoding = ObjectEncoding.AMF0;

bcbirk100
01-07-2008, 05:39 PM
Well that's good to know. I thought it might have something to do with using as3 with fms2. However this hasn't solved my problem. I tried setting the defaultObject encoding and I tried setting it for the netconnection instance I created. neither has worked. I tried looking into the system security to see if that might be causing the problem and didn't read anything that said it would, but to be safe I changed the system security to always in my html. Any other thoughts as to why it's not working? thanks again for your help.

bcbirk100
01-07-2008, 06:15 PM
I figured out that I'm connecting to the server fine, but it's not showing that it's trying to stream a file.. when i check the server I don't see my stream, which I should if it was working correctly. And I'm not getting any errors thrown either. But i know the code works with progressive, so it should work with streaming.

krom
04-02-2008, 05:47 PM
Were there any solutions to your problem? I am experiencing similar issues though in AS2.0.