[FMS]FMS3进行在线视频的录制与视频回放代码示例(4)
通过本文的基础上可以很方便的扩展出在线拍照等多种应用,有兴趣的朋友可以去试验下。下面是本文完整的示例代码。 package { importflash.net.*; importflash.events.*; importflash.media.*; importflash.display.
通过本文的基础上可以很方便的扩展出在线拍照等多种应用,有兴趣的朋友可以去试验下。下面是本文完整的示例代码。
- package
- {
- import flash.net.*;
- import flash.events.*;
- import flash.media.*;
- import flash.display.*;
- import fl.controls.*;
- public class PublishPlay extends Sprite
- {
- private var nc:NetConnection;
- private var ns:NetStream;
- private var video:Video;
- private var cam:Camera;
- private var mic:Microphone;
- public function PublishPlay():void
- {
- lbName.text="请输入视频文件名:";
- btnPublish.label="开始录制";
- btnPublish.addEventListener(MouseEvent.CLICK,onPublishClick);
- btnStop.label="停止录制";
- btnStop.addEventListener(MouseEvent.CLICK,onStopHandler);
- btnPlay.label="视频回放";
- btnPlay.addEventListener(MouseEvent.CLICK,onPlayHandler);
- video=new Video();
- cam = Camera.getCamera();
- mic = Microphone.getMicrophone();
- if(cam==null)
- {
- trace("没检测到视频摄像头");
- }
- else
- {
- video.attachCamera(cam);
- }
- addChild(video);
- }
- private function onStatusHandler(evt:NetStatusEvent):void
- {
- trace(evt.info.code);
- if(evt.info.code=="NetConnection.Connect.Success")
- {
- ns=new NetStream(nc);
- ns.addEventListener(NetStatusEvent.NET_STATUS,onStatusHandler);
- ns.client=new CustomClient();
- }
- }
- private function onPublishClick(evt:MouseEvent):void
- {
- nc=new NetConnection();
- nc.addEventListener(NetStatusEvent.NET_STATUS,onPublishStatusHandler);
- nc.connect("rtmp://localhost/PulishedStreams");
- }
- private function onPublishStatusHandler(evt:NetStatusEvent):void
- {
- if(evt.info.code=="NetConnection.Connect.Success")
- {
- ns=new NetStream(nc);
- ns.addEventListener(NetStatusEvent.NET_STATUS,onPublishStatusHandler);
- ns.client=new CustomClient();
- ns.attachCamera(cam);
- ns.attachAudio(mic);
- ns.publish(tbName.text,"record");
- }
- }
- private function onStopHandler(evt:MouseEvent):void
- {
- nc.close();
- }
- private function onPlayHandler(evt:MouseEvent):void
- {
- nc=new NetConnection();
- nc.addEventListener(NetStatusEvent.NET_STATUS,onPlayStatusHandler);
- nc.connect("rtmp://localhost/PulishedStreams");
- }
- private function onPlayStatusHandler(evt:NetStatusEvent):void
- {
- if(evt.info.code=="NetConnection.Connect.Success")
- {
- ns=new NetStream(nc);
- ns.addEventListener(NetStatusEvent.NET_STATUS,onPlayStatusHandler);
- ns.client=new CustomClient();
- video = new Video();
- video.attachNetStream(ns);
- ns.play(tbName.text,0);
- addChild(video);
- }
- }
- }
- }
http://www.cnblogs.com/beniao/archive/2009/04/26/1415342.html
热门文章推荐
- [FMS]Adobe FMS产品(Adobe Flash Media Server)使用介绍(组图)
- [FMS]Flash Media Server之教程附示例代码
- [RTMP]国产RTMP/HLS直播服务器simple-rtmp-server
- [WOWZA]用wowza流媒体服务器发布和播放直播流(RTMP)
- [RTMP]又一款rtmp类的服务器openrtmfp流媒体服务器
- [RTMP]adobe之FMS视频直播解决方案流程介绍(组图)
- [RTMP协议]实时消息传输协议 (RTMP) 常识性介绍
- [FMS]Adobe的Flash Media Server服务器(FMS服务器)安装
请稍候...