Below is a basic code bit in as3 flash.A simple video streaming example using rtmp red5. 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.( i have verified the installed demo of ofla by running it properly) 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 get it actually playing.
netStatusHandler NetConnection.Connect.Success
netStatusHandler NetStream.Play.Reset
netStatusHandler NetStream.Play.Start
what am i missing here in regards to giving the path to the video file ? they are located in the same demo example folder which come with the default red5 installation.
package
{
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.net.*
public class NetConnectionExample extends MovieClip
{
private var videoURL:String = "rtmp://localhost/oflaDemo/streams";
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;
case "NetStream.Play.Start":
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+"avatar.flv");
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);
}
}
Edit: Related Where do I place a FLV file to stream on a local Red5 server?