Page 1 of 1
[VideoConference] Check how many people are on camera
Posted: 06 Aug 2013, 19:37
by RiccardoNL
Hi all,
I'm playing around with the VideoConference sample. Is there a way to check how many people are on camera?
I see every liveCast gets an id. My goal is to prevent users from starting broadcasting, as soon as there are 8 people on cam. I tried something like this in VideoConference.as:
Code: Select all
if(!videoContainer.contains(liveCast.8)
{
bt_joinConf.enabled = false;
bt_leaveConf.enabled = true;
}
Am I on the right track? I think I'm overlooking something..
Riccardo
Re: [VideoConference] Check how many people are on camera
Posted: 07 Aug 2013, 08:25
by Bax
You can use the AVCastManager.getAvailableCasts() method. The list of LiveCast objects returned can be used to determine how many users are sending their stream in the current Room.
Re: [VideoConference] Check how many people are on camera
Posted: 11 Aug 2013, 15:06
by RiccardoNL
Hi Bax,
Thank you for your reply. The aim is to check if there are 8 users on cam. If there are 8 users broadcasting, I want the JoinConference button to be inactive.
How can I let it check there are 8 people on cam? Through getAvailableCasts I only get DisplayObject errors..
Riccardo
Re: [VideoConference] Check how many people are on camera
Posted: 12 Aug 2013, 08:03
by Bax
DId you check the API documentation of that method? It returns an array of object, one for each active stream. If the list contains 8 items, then 8 users are on cam.
Re: [VideoConference] Check how many people are on camera
Posted: 12 Aug 2013, 17:39
by RiccardoNL
Hi Bax,
I checked it and used it in my code. But now the length of getAvailableCasts is always 0. And yes, I joined the room already.
This is the code I used:
Code: Select all
public function onLiveCastPublished(evt:RedBoxCastEvent):void
{
var liveCast:LiveCast = evt.params.liveCast;
trace ("User " + liveCast.username + " published his live cast");
// Subscribe live cast and add to video container
addLiveCast(liveCast);
countcasts();
}
Code: Select all
public function countcasts():void
{
// Retrieve live casts
var castsArray:Array = avCastMan.getAvailableCasts();
trace("LENGTH :", castsArray.length);
}
Even if I trace it like: trace("LENGTH :", avCastMan.getAvailableCasts().length); - the length is always 0.
Re: [VideoConference] Check how many people are on camera
Posted: 13 Aug 2013, 08:32
by Bax
I'm sorry, I made a mistake. The array returned by the avCastMan.getAvailableCasts() method is an associative array, which means that the length property doesn't work.
You have to run a for-loop and count the items, like this:
Code: Select all
var cnt:int = 0;
for each (var lc:LiveCast in castsArray)
cnt++;
Re: [VideoConference] Check how many people are on camera
Posted: 13 Aug 2013, 20:43
by RiccardoNL
Bax,
That did the trick
. Thank you so much for helping me out and you incredible patience with me.
Riccardo