感谢arrow指导http://blog.smilecn.net
i make this script by flexbuild3,sothis is a mxml file,it is mainly to test the fms netconnect and maybe test the fms resources consumes.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="" layout="absolute">
<mx:Script>
<![CDATA[
// ActionScript file
import flash.events.NetStatusEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
public var nc:NetConnection;
public var localVideo:Video;
public var inStream:NetStream = null;
public function conn():void
{
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nc.connect("rtmp://192.168.0.100/vod/meida");
nc.client = this;
trace("connecting....")
}
private function netStatusHandler(event:NetStatusEvent):void
{
trace("connected is: " + nc.connected);
trace("event.info.level: " + event.info.level);
trace("event.info.code: " + event.info.code);
//查看返回信息
switch (event.info.code)
{
case "NetConnection.Connect.Failed":
trace("Congratulations! you're connected" + "\n");
case "NetConnection.Connect.Success":
connectionStream();
//连接后播放
break;
case "NetStream.Play.StreamNotFound":
trace("Thanks! the connection has been closed" + "\n");
break;
}
}
public function connectionStream():void
{
var metaObject:Object=new Object();
metaObject.onMetaData=onMetaData;
// onMetaData :在 Flash Player 接收到正在播放的视频中嵌入的描述性信息时建立侦听器进行响应 . 实际上是 NetStream.client 对象的属性。它不是一个事件,之所以列在事件部分,是因为它在流媒体使用 Flash Media Server 时或在 FLV 文件回放过程中响应数据事件
inStream = new NetStream(nc);
inStream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
localVideo = new Video();
localVideo.x = 0;
localVideo.y = 0;
localVideo.width = 320;
localVideo.height = 240;
localVideo.attachNetStream(inStream);
inStream.play("AdobeBand_640");
nc.client=metaObject;
myVideo.addChild(localVideo);
}
public function onBWDone(...rest):void
{
}
private function onMetaData(data:Object):void {
//发送Flash需要的Metadata数据
}
]]>
</mx:Script>
<mx:VideoDisplay id="myVideo" x="0" y="0" height="240" width="320" creationComplete="conn();"/>
</mx:Application>
|
阅读(586) | 评论(0) | 转发(0) |