客户端部分:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="init()"><fx:Declarations><!-- 将非可视元素(例如服务、值对象)放在此处 --></fx:Declarations><mx:UIComponent id="ui"></mx:UIComponent><fx:Script><![CDATA[import mx.controls.Alert;private var rtmpURL:String="rtmp://10.10.80.62/version0.1";private var conn:NetConnection=new NetConnection();private var isConnectSuccess:Boolean=false;private var netStream:NetStream;private var video:Video=new Video();// public function metaDataHandler(infoObject:Object):void {} // 创建回调函数的对象public var customClient:Object=new Object();public function init():void{conn.connect(rtmpURL);conn.addEventListener(NetStatusEvent.NET_STATUS,netStatus);}private function netStatus(e:NetStatusEvent):void{trace(e.info.code);switch(e.info.code){case "NetConnection.Connect.Success":{playad();break;}case "NetStream.Play.Stop" :{}}}public function playad():void{isConnectSuccess=true;netStream=new NetStream(conn);netStream.addEventListener( NetStatusEvent.NET_STATUS,netStatus);video.attachNetStream(netStream);video.width = 800;video.height = 1000;// customClient.onMetaData = metaDataHandler;netStream.client=customClient; netStream.play("ad.flv");ui.addChild(video); }]]></fx:Script>
<!-- <mx:Button x="200" y="200" label="connect" click="this.clickConnect(event)"/>--> </s:Application>
服务器部分:
import org.red5.server.adapter.Applic ationAdapter;
import org.red5.server.api.IConnection;
public class Application extends ApplicationAdapter {
public boolean appConnect(IConnection conn, Object[] args) {
System.out.println(" 连接");
return true;
}
软件版本:
adobe flash builder 4.6
red5 09.1