Copy link to clipboard
Copied
Sorry don't have much time to write detailed code, but following is bare minimum which i think should work for you, you can modify and add detail later and customize it to suit your need:
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.*;
import flash.system.Capabilities;
var nc:NetConnection;
var resp1:Responder;
var resp2:Responder;
function onCallSuccess(resObj):void{
for(var i in resObj){
trace("NetStream Top Level data:"+i);
trace("NetStream Top Level value:"+res
...Copy link to clipboard
Copied
As of now I will give you example with http and later will try to post AS3 example
Take your example: You are publishing with name "livefeedLive" to application called "liveVideo" (assuming admin/admin as userid/password for Admin)
Run this command in browser: http://<server-ip>:1111/admin/getNetStreams?auser=admin&apswd=admin&appInst= liveVideo/_definst_
This will give you below result: (just a sample result)
Copy link to clipboard
Copied
First I want to say thanks for your help
Copy link to clipboard
Copied
Sorry don't have much time to write detailed code, but following is bare minimum which i think should work for you, you can modify and add detail later and customize it to suit your need:
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.*;
import flash.system.Capabilities;
var nc:NetConnection;
var resp1:Responder;
var resp2:Responder;
function onCallSuccess(resObj):void{
for(var i in resObj){
trace("NetStream Top Level data:"+i);
trace("NetStream Top Level value:"+resObj);
if( i.toString() == "data"){
for(var j in resObj){
trace("NetStream Low Level Data:"+j);
trace("NetStream Low Level Value:"+resObj
if(resObj
nc.call("getNetStreamStats",resp2,"live/_definst_",resObj
}
}
}
}
}
function onCallSuccess2(resObj):void{
//write similar code as onCallSuccess as per your req
for(var m in resObj){
trace("NetStreamStats Top Level Data:"+resObj
for(var n in resObj
for(var o in resObj
trace("NetStreamStats Low Level Data:"+resObj
}
}
}
}
nc = new NetConnection();
resp1 = new Responder(onCallSuccess,null);
resp2 = new Responder(onCallSuccess2,null);
nc.addEventListener(NetStatusEvent.NET_STATUS, script_ncStatus);
function script_ncStatus(event:NetStatusEvent):void{
var info:Object = event.info;
if(info.code=="NetConnection.Connect.Success"){
nc.call("getNetStreams",resp1,"live/_definst_");
}
}
nc.connect("rtmp://<server-ip>/admin","admin","admin");
There are lot other codes which you can use to get other statistics in above fashion , like getLiveStreams,getLiveStreamStats - please refer Admin API guide which comes with FMS installation.
Hope it works for you.
Copy link to clipboard
Copied
because this response is so : NetStreamStats Top Level Data:[object Object]
one other small question how to intercept (via actionscript 3) if live video feed has audio
the publisher is the normal webcam usb
Copy link to clipboard
Copied
I know what i am telling is cryptic way but i dont know what is your use case, but what you can do is just play the stream via netstream at client end and define handler for your metadata. If your metadata contains audiocodecId field , it has audio , and if there is no such field in metadata there is no audio
Copy link to clipboard
Copied
Copy link to clipboard
Copied
These are the two files that I use, one for sending the video and audio from a webcam and another that does only see
______________________________________________________________________________
publisher.fla
var nc:NetConnection;
var ns:NetStream;
var vid:Video;
var cam:Camera;
var mic:Microphone;
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
nc.connect("rtmp://192.168.1.10/detectAudioFromLive");
function onNetStatus(event:NetStatusEvent):void {
trace(event.info.code);
if (event.info.code=="NetConnection.Connect.Success") {
cam=Camera.getCamera();
mic=Microphone.getMicrophone();
ns=new NetStream(nc);
cam.setQuality(0,100);
cam.setMode(320,240,25);
ns.attachCamera(cam);
ns.attachAudio(mic);
var metaData:Object = new Object();
metaData.title="liveCameraInfo";
metaData.width=320;
metaData.height=240;
ns.send("@setDataFrame", "onMetaData", metaData);
//then publish video
ns.publish("liveCamera", "live");
vid.x=10;
vid.y=10;
vid.attachCamera(cam);
addChild(vid);
}
}
_______________________________________________________________________________
viewer.fla
var nc:NetConnection;
var ns:NetStream;
var vid:Video;
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
nc.connect("rtmp://192.168.1.10/detectAudioFromLive");
function onNetStatus(event:NetStatusEvent):void {
trace(event.info.code);
if (event.info.code=="NetConnection.Connect.Success") {
ns=new NetStream(nc);
ns.play("liveCamera");
//then view livevideo in the stage
//vid = new Video();//this method create new video
vid.x=10;
vid.y=10;
vid.attachNetStream(ns);
addChild(vid);
}
}
var obj:Object = new Object();
function onMetaData(info:Object):void {
//outputWindow.appendText(info.customProp);
metaData.text=info.customProp;
trace(info.customProp);
var msg:String;
msg=info.customProp;
}