getAvailableCasts() always returns 0 length array

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

Moderators: Lapo, Bax

Satyarth
Posts: 131
Joined: 06 Nov 2008, 12:45
Location: Delhi, India
Contact:

getAvailableCasts() always returns 0 length array

Postby Satyarth » 01 Jun 2011, 20:00

I am not sure what i am doing wrong. But getAvailableCasts() function always returns array with 0 length.

Lapo please comment


Piece of my code :

private function onLiveCastPublished(ev:RedBoxCastEvent):void
{
var liveCast:LiveCast = ev.params.liveCast

// Subscribe live cast
var stream:NetStream = avCastMan.subscribeLiveCast(liveCast.id);

...... //Some other code

}

private function onAVCastConnectionInited(ev:RedBoxCastEvent):void {

/*Listen for live broadcasts*/
var castsArray:Array = avCastMan.getAvailableCasts();
trace("LENGTH :", castsArray.length); //ALWAYS 0
.... //Some other code
}

public function publishLiveCast():void
{
try{
avCastMan.publishLiveCast(true, true);
}
catch(e:NoAVConnectionException)
{
/*Show Error Popup to the user*/
dispatchEvent(new Event("RedBoxConnectionError"));
}
}
Satyarth
Posts: 131
Joined: 06 Nov 2008, 12:45
Location: Delhi, India
Contact:

[solved]

Postby Satyarth » 02 Jun 2011, 12:08

Solved the issue. To have getAvailableCasts() work for you, you need to make sure that it is called after SmartFox room is joined.

In my case there was a race condition and getAvailableCasts() was being called before room was joined.
darrenortiz
Posts: 9
Joined: 06 Jan 2012, 22:38

same problem

Postby darrenortiz » 06 Jan 2012, 23:03

I'm having the same problem, only waiting to make sure I join a room doesn't help. No matter what I've tried, the getAvailableCasts is always empty or null.
darrenortiz
Posts: 9
Joined: 06 Jan 2012, 22:38

Fixed

Postby darrenortiz » 07 Jan 2012, 16:57

So I've solved my problem regarding the empty getAvailableCasts array. It's not that it's empty. It's that it's an associative array.

So instead of doing:
for(i=0; i < length; i++)

You have to do:
for each(var livecast:LiveCast in array)

Although the first method should work regardless, it's actually because I was limiting "length" to the max number of streams I was expecting.
So I was doing:
length = Math.min(getAvailableCasts.length, maxStreams)

*pseudo code*

Return to “RedBox”

Who is online

Users browsing this forum: No registered users and 1 guest