플래시builder+red5로 간단한 플레이어 실례

2424 단어
<?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

좋은 웹페이지 즐겨찾기