Page 1 of 1

getAvailableCasts() always returns 0 length array

Posted: 01 Jun 2011, 20:00
by Satyarth
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"));
}
}

[solved]

Posted: 02 Jun 2011, 12:08
by Satyarth
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.

same problem

Posted: 06 Jan 2012, 23:03
by darrenortiz
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.

Fixed

Posted: 07 Jan 2012, 16:57
by darrenortiz
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*