Groups | Blog | Home
all groups > macromedia flash flashcom > june 2007 >

macromedia flash flashcom : Number of viewers of live stream


Albert780
6/21/2007 12:00:00 AM
Hello,

I want to display the number of viewers that are watching a video stream on a
website... I am using FMS 2, and this is the actionscript of the flash file:

connect_pb.onRelease = function(){
if(this.label == "Start Watching"){
this.label = "Stop Watching";
nc.connect("rtmp:/livecast");
} else {
this.label = "Start Watching";
nc.close();
}
}

nc = new NetConnection();
nc.onStatus = function(info) {
createNetStream(this);
}

createNetStream = function(nc){
ns = new NetStream(nc);
myvid.attachVideo(ns);
ns.play(stream, -1)
}

(it displays the video another user is streaming through his webcam).

How can I add the number of viewers of this video to the flash?

Thanks.
Albert780
7/1/2007 12:00:00 AM
Basically, this is the actionscript I have for the "Broadcaster" application:

/* first create a new instance of the LoadVars object */
myVars = new LoadVars();
// call the load method to load my php page
myVars.load("hs.php");

startstop_pb.enabled = false;

connect_pb.onRelease = function(){
if(this.label == "Connect"){
this.label = "Disconnect";
nc.connect("rtmp:/livecast");
} else {
this.label = "Connect";
nc.close();
}
}

nc = new NetConnection();
nc.onStatus = function(info) {
startstop_pb.enabled = true;
createNetStream(this);
}

createNetStream = function(nc){
ns = new NetStream(nc);
mycam = Camera.get();
mycam.setQuality(25600, 0);
mymic = Microphone.get();
mymic.setRate(11);
ns.attachVideo(mycam);
ns.attachAudio(mymic);
myvid.attachVideo(mycam);
}

startstop_pb.onRelease = function(){
if (this.label == "Start Broadcast"){
this.label = "Stop Broadcast";
ns.publish(myVars.hs, "live");

} else {
this.label = "Start Broadcast";
myvid.attachVideo(null);
myvid.clear();
ns.close();
}
}


---- On the other side, a "Receiver" application displays the stream that has
been published.

How do I display the number of viewers, or the number of "receivers"
subscribed to the published stream?

(example: http://www.ustream.tv - they use FMS2).
flv2048
7/9/2007 4:27:12 PM
actually I am trying to do something similar. However I wan't it to be server
wide and store the information in some kind of php or asp variable that I could
pass back to my Server Side Script so when my license limit is reached on could
foward the user to a differnt page, rather than having them see a blank screen
AddThis Social Bookmark Button