[RED5]运用Flex与Red5实现视频直播源代码
服务器端可以空实现ApplicationAdapter:示例如下,客户端使用Flex实现摄像头获取视频并发布代码如下
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="CuPlayer现场直播" fontSize="14">
- <mx:VideoDisplay x="10" y="10" width="320" height="193" id="videoDisplay"/>
- </mx:Panel>
- </mx:Application>
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...