HI,
i’m new to streaming media and i’m using red5 server,i try to play a flv,but it always showing netconnection.connet.rejected.please help me on this,whether i have to import server side code.
my code:AS3
import fl.controls.ComboBox;
var myNc:NetConnection = null
var myNs:NetStream = null
var myVideo:Video
var myVideoObj:Object
var strVideoName:String
var myComboBox
init()
function init()
{
createComboBox()
}
function createComboBox()
{
myComboBox = new ComboBox()
myComboBox.setSize(150, 22);
myComboBox.prompt = “Select a destination”;
myComboBox.addItem( { label: “Server”, data:“rtmp://localhost/AudioTest” } );
myComboBox.addItem( { label: “Client”, data:null } );
myComboBox.addEventListener(Event.CHANGE, selectedPath);
addChild(myComboBox)
}
function selectedPath(e:Event):void {
trace(myComboBox.selectedItem.label);
if(myVideo != null)
{
myNs.close()
removeChild(myVideo)
myNs = null
myVideoObj = null
myVideo = null
}
switch(myComboBox.selectedItem.label)
{
case “Server”:
trace(“connection Failed”)
strVideoName =“stream”
break;
case “Client”:
strVideoName = “test.flv”
break;
default:
}
createConnection(myComboBox.selectedItem.data)
}
function createConnection(pValue)
{
myNc = new NetConnection()
myNc.addEventListener(NetStatusEvent.NET_STATUS, connectionStatusHandler)
myNc.connect(pValue)
}
function connectionStatusHandler(evt)
{
switch(evt.info.code)
{
case “NetConnection.Connect.Failed”:
trace(“connection Failed”)
break;
case “NetConnection.Connect.Rejected”:
trace(“connection Failed”)
break;
case “NetConnection.Connect.Success”:
createStream()
break;
default:
}
}
function createStream()
{
if(myNs == null)
{
myNs = new NetStream(myNc)
myNs.addEventListener(NetStatusEvent.NET_STATUS,streamStatusHandler)
}
buildVideo()
}
function streamStatusHandler(evt)
{
switch(evt.info.code)
{
case “NetStream.Play.Stop”:
trace(“video stopped”)
break;
case “NetStream.Play.Start”:
trace(“video started”)
break;
case “NetStream.Buffer.Full”:
//trace(“video Buffer.Full”)
break;
default:
}
}
function buildVideo()
{
myVideoObj = new Object()
myNs.client = myVideoObj
myNs.play(strVideoName)
myVideo = new Video()
myVideo.x = 100
myVideo.y = 100
myVideo.attachNetStream(myNs)
addChild(myVideo)
}
:hr: