[RED5]Flex基于Red5的视频直播源代码
[RED5]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.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://test.cuplayer.com/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>
[RED5]Flex基于Red5的视频直播源代码
热门文章推荐
- [Red5]Red5之Flash流媒体服务器的安装与使用教程完整版(组图)
- [RED5]搭建RED5直播用流媒体服务(搭直播环境)
- [RED5]Red5的直播与点播的压力测试(并发数的测试)
- [RED5]red5流媒体服务器(开源免费)的安装方法
- [RED5]用red5做视频直播(red5流媒体直播)
- [RED5]Red5在线录制音视频源代码示例
- [RED5]Red5 Client 连接 Red5Server java代码
- [RED5]red5流媒体播放平台搭建环境方法
请稍候...