求问,哪里有flex 和red5 的视频教程。新手,要详细的系统教程。
展开全部
1,服务器端可以空实现ApplicationAdapter:示例如下:
package org.chy.flex01;
import org.red5.server.adapter.ApplicationAdapter;
public class Application extends ApplicationAdapter{
}
客户端使用Flex实现摄像头获取视频并发布代码如下:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()">
<mx:Script>
<!--[CDATA[
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.NetStatusEvent;
import mx.controls.Alert;
private var nc:NetConnection;
private var ns:NetStream;
private var cam:Camera;
private function init():void{
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS,connectServerHander);
nc.client = this;
nc.connect("rtmp://58.116.56.68:1935/Flex01");
}
private function connectServerHander(evt:NetStatusEvent):void{
trace(evt.info.code);
cam = Camera.getCamera();
if(cam != null){
cam.setMode(313,194,30);
cam.setQuality(0,70);
ns = new NetStream(nc);
ns.attachCamera(cam);
ns.publish("red5");
var vi:Video = new Video();
vi.width = 313;
vi.height = 194;
vi.attachCamera(cam);
videoDisplay.addChild(vi);
}else{
Alert.show("no Camera");
}
}
public function onBWDone():void{
}
]]-->
</mx:Script>
<mx:VideoDisplay x="162" y="77" width="313" height="194" id="videoDisplay"/>
</mx:Application>
客户端使用Flex play视频代码如下:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()">
<mx:Script>
<!--[CDATA[
import flash.display.*;
import flash.utils.*;
import flash.events.*;
import flash.net.*;
import flash.media.Video;
import flash.media.Camera;
private var nc:NetConnection;
private function init():void{
nc = new NetConnection();
nc.connect("rtmp://58.116.56.68:1935/Flex01");
nc.addEventListener(NetStatusEvent.NET_STATUS,connectHandler);
}
private function connectHandler(evt:NetStatusEvent):void{
var ns:NetStream = new NetStream(nc);
var video:Video=new Video() ;
video.width = 313;
video.height = 194;
video.attachNetStream(ns);
ns.play("red5");
videoDisplay.addChild(video);
}
]]-->
</mx:Script>
<mx:Panel x="132" y="78" width="356" height="266" layout="absolute" title="现场直播" fontSize="14">
<mx:VideoDisplay x="10" y="10" width="320" height="193" id="videoDisplay"/>
</mx:Panel>
</mx:Application>
package org.chy.flex01;
import org.red5.server.adapter.ApplicationAdapter;
public class Application extends ApplicationAdapter{
}
客户端使用Flex实现摄像头获取视频并发布代码如下:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()">
<mx:Script>
<!--[CDATA[
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.NetStatusEvent;
import mx.controls.Alert;
private var nc:NetConnection;
private var ns:NetStream;
private var cam:Camera;
private function init():void{
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS,connectServerHander);
nc.client = this;
nc.connect("rtmp://58.116.56.68:1935/Flex01");
}
private function connectServerHander(evt:NetStatusEvent):void{
trace(evt.info.code);
cam = Camera.getCamera();
if(cam != null){
cam.setMode(313,194,30);
cam.setQuality(0,70);
ns = new NetStream(nc);
ns.attachCamera(cam);
ns.publish("red5");
var vi:Video = new Video();
vi.width = 313;
vi.height = 194;
vi.attachCamera(cam);
videoDisplay.addChild(vi);
}else{
Alert.show("no Camera");
}
}
public function onBWDone():void{
}
]]-->
</mx:Script>
<mx:VideoDisplay x="162" y="77" width="313" height="194" id="videoDisplay"/>
</mx:Application>
客户端使用Flex play视频代码如下:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()">
<mx:Script>
<!--[CDATA[
import flash.display.*;
import flash.utils.*;
import flash.events.*;
import flash.net.*;
import flash.media.Video;
import flash.media.Camera;
private var nc:NetConnection;
private function init():void{
nc = new NetConnection();
nc.connect("rtmp://58.116.56.68:1935/Flex01");
nc.addEventListener(NetStatusEvent.NET_STATUS,connectHandler);
}
private function connectHandler(evt:NetStatusEvent):void{
var ns:NetStream = new NetStream(nc);
var video:Video=new Video() ;
video.width = 313;
video.height = 194;
video.attachNetStream(ns);
ns.play("red5");
videoDisplay.addChild(video);
}
]]-->
</mx:Script>
<mx:Panel x="132" y="78" width="356" height="266" layout="absolute" title="现场直播" fontSize="14">
<mx:VideoDisplay x="10" y="10" width="320" height="193" id="videoDisplay"/>
</mx:Panel>
</mx:Application>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
南京林科斯拉信息技术
2024-12-16 广告
2024-12-16 广告
南京林科斯拉信息技术有限公司成立于2018年,是人工智能研究院的孵化企业,深度合作研究院提供机器学习的核心算法和应用指导。公司以机器学习算法为核心,以“SaaS平台+人工值守”为主要模式,为用户提供专业、高效、安全的IT运维服务。 林科斯拉...
点击进入详情页
本回答由南京林科斯拉信息技术提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询