[VideoConference] Check how many people are on camera

Post your questions and bug-reports about our audio/video streaming add-on based on Red5 Server.

Moderators: Lapo, Bax

RiccardoNL
Posts: 35
Joined: 01 Apr 2013, 20:53

[VideoConference] Check how many people are on camera

Postby RiccardoNL » 06 Aug 2013, 19:37

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
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: [VideoConference] Check how many people are on camera

Postby Bax » 07 Aug 2013, 08:25

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.
Paolo Bax
The SmartFoxServer Team
RiccardoNL
Posts: 35
Joined: 01 Apr 2013, 20:53

Re: [VideoConference] Check how many people are on camera

Postby RiccardoNL » 11 Aug 2013, 15:06

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
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: [VideoConference] Check how many people are on camera

Postby Bax » 12 Aug 2013, 08:03

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.
Paolo Bax
The SmartFoxServer Team
RiccardoNL
Posts: 35
Joined: 01 Apr 2013, 20:53

Re: [VideoConference] Check how many people are on camera

Postby RiccardoNL » 12 Aug 2013, 17:39

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.
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: [VideoConference] Check how many people are on camera

Postby Bax » 13 Aug 2013, 08:32

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++;
Paolo Bax
The SmartFoxServer Team
RiccardoNL
Posts: 35
Joined: 01 Apr 2013, 20:53

Re: [VideoConference] Check how many people are on camera

Postby RiccardoNL » 13 Aug 2013, 20:43

Bax,

That did the trick :). Thank you so much for helping me out and you incredible patience with me.

Riccardo

Return to “RedBox 2X”

Who is online

Users browsing this forum: No registered users and 3 guests