Below is a sample application i have been developing in as3 flash based on ofla demo. But i seem to be having issues connecting to the stream.I am using the same video files as given with the red5 server demo installation.
my output trace traces out as a connection success and the play start of the video file. But i am unable to get its metadata or see it actually playing on the stage.
Quote
netStatusHandler NetConnection.Connect.Success
netStatusHandler NetStream.Play.Reset
netStatusHandler NetStream.Play.Start
netStatusHandler NetStream.Play.Reset
netStatusHandler NetStream.Play.Start
getting this right would help in converting/reworking some of the as2 examples into as3.
package
{
import flash.display.*;
import flash.events.NetStatusEvent;
import flash.events.*;
import flash.media.*;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.Event;
public class NetConnectionExample extends MovieClip
{
private var videoURL:String = "rtmp://localhost/oflaDemo/streams/avatar.flv";
private var connection:NetConnection;
private var stream:NetStream;
public function NetConnectionExample()
{
// constructor code
connection = new NetConnection();
connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
connection.connect(videoURL, true);
}
private function netStatusHandler(event:NetStatusEvent):void
{
trace("netStatusHandler",event.info.code);
switch (event.info.code)
{
case "NetConnection.Connect.Success":
connectStream();
break;
case "NetStream.Play.StreamNotFound":
trace("Stream not found: " + videoURL);
break;
}
}
private function securityErrorHandler(event:SecurityErrorEvent):void
{
trace("securityErrorHandler: " + event);
}
private function connectStream():void
{
stream = new NetStream(this.connection);
stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler)
stream.client = new CustomClient();
var video:Video = new Video();
video.attachNetStream(stream);
stream.play(videoURL);
addChild(video);
}
function asyncErrorHandler(event:AsyncErrorEvent):void {
// ignore AsyncErrorEvent events.
}
}
}
class CustomClient {
public function onMetaData(info:Object):void
{
trace("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate);
}
public function onCuePoint(info:Object):void
{
trace("cuepoint: time=" + info.time + " name=" + info.name + " type=" + info.type);
}
}


Recent Topics Added


















