package {
import flash.display.MovieClip;
import flash.net.NetConnection;
import flash.events.NetStatusEvent;
import flash.events.MouseEvent;
import flash.events.AsyncErrorEvent;
import flash.net.NetStream;
import flash.media.Video;
import flash.media.Camera;
import flash.media.Microphone;
import fl.controls.Button;
import fl.controls.Label;
import fl.controls.TextArea; public class Metadata extends MovieClip {
private var nc:NetConnection;
private var ns:NetStream;
private var nsPlayer:NetStream;
private var vid:Video;
private var vidPlayer:Video;
private var cam:Camera;
private var mic:Microphone;
private var clearBtn:Button;
private var startPlaybackBtn:Button;
private var outgoingLbl:Label;
private var incomingLbl:Label;
private var myMetadata:Object;
private var outputWindow:TextArea; public function Metadata(){
setupUI();
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
nc.connect("rtmp://localhost/publishlive");
} /*
* Clear the MetaData associated with the stream
*/
private function clearHandler(event:MouseEvent):void {
if (ns){
trace("Clearing MetaData");
ns.send("@clearDataFrame", "onMetaData");
}
} private function startHandler(event:MouseEvent):void {
displayPlaybackVideo();
} private function onNetStatus(event:NetStatusEvent):void {
trace(event.target + ": " + event.info.code);
switch (event.info.code)
{
case "NetConnection.Connect.Success":
publishCamera();
displayPublishingVideo();
break;
}
} private function asyncErrorHandler(event:AsyncErrorEvent):void {
trace(event.text);
} private function sendMetadata():void {
trace("sendMetaData() called")
myMetadata = new Object();
myMetadata.customProp = "This message is sent by @setDataFrame.";
ns.send("@setDataFrame", "onMetaData", myMetadata);
} private function publishCamera():void {
cam = Camera.getCamera();
mic = Microphone.getMicrophone();
ns = new NetStream(nc);
ns.client = this;
ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
ns.attachCamera(cam);
ns.attachAudio(mic);
ns.publish("myCamera", "record");
sendMetadata(); } private function displayPublishingVideo():void {
vid = new Video(cam.width, cam.height);
vid.x = 10;
vid.y = 10;
vid.attachCamera(cam);
addChild(vid);
} private function displayPlaybackVideo():void {
nsPlayer = new NetStream(nc);
nsPlayer.client = this;
nsPlayer.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
nsPlayer.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
nsPlayer.play("myCamera", 1);
vidPlayer = new Video(cam.width, cam.height);
vidPlayer.x = cam.width + 100;
vidPlayer.y = 10;
vidPlayer.attachNetStream(nsPlayer);
addChild(vidPlayer);
} private function setupUI():void {
outputWindow = new TextArea();
outputWindow.move(250, 175);
outputWindow.width = 250;
outputWindow.height = 150; outgoingLbl = new Label();
incomingLbl = new Label();
outgoingLbl.width = 150;
incomingLbl.width = 150;
outgoingLbl.text = "Publishing Stream";
incomingLbl.text = "Playback Stream";
outgoingLbl.move(30, 150);
incomingLbl.move(300, 150); startPlaybackBtn = new Button();
startPlaybackBtn.width = 150;
startPlaybackBtn.move(250, 345)
startPlaybackBtn.label = "View Live Event";
startPlaybackBtn.addEventListener(MouseEvent.CLICK, startHandler); clearBtn = new Button();
clearBtn.width = 100;
clearBtn.move(135,345);
clearBtn.label = "Clear Metadata";
clearBtn.addEventListener(MouseEvent.CLICK, clearHandler); addChild(clearBtn);
addChild(outgoingLbl);
addChild(incomingLbl);
addChild(startPlaybackBtn);
addChild(outputWindow);
} public function onMetaData(info:Object):void {
var key:String;
for (key in info){
outputWindow.appendText(key + ": " + info[key] + "\n");
}
}
public function onTimeCoordInfo(info:Object):void{
for (var key:String in info){
trace(key + ": " + info[key] + "\n");
}
}
}
}

[ActionSprit 3.0] FMS接收正在播放的视频中嵌入的描述性信息(onMetaData事件)的更多相关文章

  1. [ActionSprit 3.0] FMS直播

    音视频流的发布(服务端) package { import flash.display.Sprite; import flash.events.NetStatusEvent; import flash ...

  2. [ActionSprit 3.0] FMS服务器带宽检测

    package { import flash.display.Sprite; import flash.net.NetConnection; import flash.events.NetStatus ...

  3. [ActionSprit 3.0] FMS客户端调用服务器端命令或方法

    有时候客户端需要和服务器端进行通信,服务器端会有个main.asc文件(当然,文件名可以自己定义),这个就是服务器端程序,是在服务器上执行的,你可以用trace调试,trace的内容会在管理服务器的页 ...

  4. [ActionSprit 3.0] FMS安装与测试

    1.运行Flash Media Server4.5.exe,安装选项可全默认,序列号可不填:输入用户名和密码需记住,登录时要用. 2.安装完成,在安装目录C:\Program Files\Adobe\ ...

  5. [ActionSprit 3.0] FMS远程共享

    package { import flash.display.Sprite; import flash.events.NetStatusEvent; import flash.events.SyncE ...

  6. [ActionSprit 3.0] FMS客户端与服务器端交互(传参)

    客户端as: import flash.net.NetConnection; import flash.events.NetStatusEvent; var nc:NetConnection = ne ...

  7. 1.0.2-学习Opencv与MFC混合编程之---为播放AVI视频添加滑动条

    源代码地址:http://download.csdn.net/detail/nuptboyzhb/3961642 版本1.0.2新增内容 Ø  全局变量和函数的添加: 在CVMFCview.cpp文件 ...

  8. 1.0.1-学习Opencv与MFC混合编程之---播放AVI视频

    资源源代码:http://download.csdn.net/detail/nuptboyzhb/3961639 版本1.0.1新增内容 Ø  新建菜单项,Learning OpenCV——> ...

  9. cocos2d-x 3.0 播放MP4视频

    猴子原创,欢迎转载.转载请注明: 转载自Cocos2D开发网–Cocos2Dev.com,谢谢! 原文地址: http://www.cocos2dev.com/?p=545 很久以前写的一个2dx播放 ...

随机推荐

  1. Kafka总结的一张图

  2. ubuntu 源码安装 lnmp 环境

    准备篇 下载软件包 1.下载nginx http://nginx.org/download/nginx-1.2.0.tar.gz 2.下载pcre  (支持nginx伪静态) ftp://ftp.cs ...

  3. 142. Linked List Cycle II (List; Two-Pointers)

    Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note ...

  4. 108.Convert Sorted Array to Binary Search Tree(Array; Divide-and-Conquer, dfs)

    Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 思路 ...

  5. Maven01 环境准备、maven项目结构、编译/测试/打包/清除、安装、

    0 前提准备 0.1 安装java开发环境 0.2 安装maven工具 1 maven项目基本结构 如图所示,整个maven项目有业务文件.测试文件.POM依赖管理文件:其实还有一个资源文件resou ...

  6. 653. Two Sum IV - Input is a BST 二叉树版本

    [抄题]: Given a Binary Search Tree and a target number, return true if there exist two elements in the ...

  7. SQL 数据库 学习 004 预备知识

    数据库 预备知识 我的电脑系统: Windows 10 64位 使用的SQL Server软件: SQL Server 2014 Express 如果我们要学习这个数据库,我们需要学习什么知识. 预备 ...

  8. Loadrunner11无法在win7 64位上启用ie解决办法

    Loadrunner11无法在win7 64位上启用ie解决办法 1.loadrunner11在win7 64位上默认启用的是32位的那个IE浏览器,路径:C:\Program Files (x86) ...

  9. 清北学堂 day6 花

    1.花( flower.cpp/c/pas)[ 问题描述]商店里出售 n 种不同品种的花.为了装饰桌面,你打算买 m 支花回家.你觉得放两支一样的花很难看,因此每种品种的花最多买 1 支.求总共有几种 ...

  10. [Training Video - 6] [File Reading] Using log object in the Groovy class

    Car c= new Car(log); c.print() class Car{ def log public Car(log){ this.log=log } public void print( ...