当前位置: 代码迷 >> Web前端 >> red5 调整到tomcat中(二)
  详细解决方案

red5 调整到tomcat中(二)

热度:523   发布时间:2012-06-28 15:20:04.0
red5 整合到tomcat中(二)

前面部署仍会有些问题。启动是会报错。这是我们需要

1,找类。在Src压缩包里找到ShutdownMXBean.java。放到项目中。

2,修改logback.xml,注释掉<consolePlugin?? />,如<!-- <consolePlugin?? /> -->。

3,在WebRoot下,新建streams目录,在里面放些flv,mp3之类的文件。

文档格式如下:



?

?

最后我们做客户端。代码如下:

<?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()"
			   >
	<s:layout>
		<s:BasicLayout/>
	</s:layout>
	<fx:Declarations>
		 
	</fx:Declarations>
	<fx:Script>
		<![CDATA[
			import mx.events.ListEvent;
			import mx.collections.ArrayCollection;
			private var rtmpURL:String="rtmp://localhost:1935/chapter2";
			private var nc:NetConnection=new NetConnection();
			private var playerVideo:Video=new Video();
			private var responder:Responder = new Responder(getMediaList);
			
			[Bindable]
			public var videoList:ArrayCollection;
			private var stream:NetStream;
			private function init():void{
				playerVideo.x=200;
				connect();
			}
			private function connect():void{
				nc.addEventListener(NetStatusEvent.NET_STATUS,netStatus);
				nc.connect(rtmpURL);
				trace("开始连接");
			}
			private function clickItem(e:ListEvent):void{
				container.addChild(playerVideo);
				stream.play(videoList.getItemAt(e.rowIndex).label);
			}
			public function getVideos():void{
				nc.call("flv.getListOfAvailableFLVs", responder);
			}
			public function getMediaList(list:Object):void{
				var mediaList:Array = new Array();
				for(var items:String in list){
					mediaList.push({label:items, size:list[items].size,
						dateModified:list[items].lastModified});
				}
				videoList = new ArrayCollection(mediaList);
			}
			private function netStatus(e:NetStatusEvent):void{
				trace(e.info.code);
				if(e.info.code=="NetConnection.Connect.Success"){
					getVideos();
					stream=new NetStream(nc);
					stream.client=new StreamClient();
					playerVideo.attachNetStream(stream);
				}
			}
		]]>
	</fx:Script>
	<mx:List itemClick="clickItem(event)" x="10" y="21" height="161"
			 dataProvider="{videoList}"></mx:List>
	<mx:UIComponent id="container">
	</mx:UIComponent>
</s:Application>

?编译运行后,点击左侧的树文件,开始播放。

?

初学者可以参考我的博客中的red5入门教程.pdf

?

  相关解决方案