At a very quick glance, have you tried:
videoObj.clear();
before assigning and attaching you NetStream to the video Object?
Cheers,
Simon
newtriks.com
On 2 Sep 2008, at 21:43, stephendricketts wrote:
I have a FB3 application that streams live video to a number of users
and periodically needs to change whose sending video. The
application pretty much has to work this way.
Let's call the person that's sending the video the "host".
Periodically they will switch hosts and let another user become the
host and send their video. This works except when the video
is "taken" the users see the new video source, but the video that's
displayed on the new host's videoDisplay is a still picture of the
first host.
Can anyone point me to how this switching should be done?... or be
willing to plow through my code and see where I've screwed up? It's
been simplified as much as I can so it makes (some) sense.
Any direction greatly appreciated!
Steve
Here's a condensed version of the code. I should also add, this is
the same program for all users. The host is only a host because they
were on first:
1. Initial Host connection:
if(nc.connected){
nsPublish = new NetStream(nc);
nsPublish.attachAudio(Microphone.getMicrophone());
nsPublish.publish("LS","live");
cam = Camera.getCamera();
if (cam != null) {
nsPublish.attachCamera(cam);
pubVideo.attachCamera(cam);
addChild(pubVideo);
}
}
2. Initial User Connection:
if (nc.connected){
pubVideo.source = rtmpPath + "/" + rtmpSession + "/LS";
}
// At this point everyone is seeing what they should.
---------------------------------------
3. User Takes Control:
<!--
Now at this point the user will write their request to a remote
shared object. Everyone is subscribed to that object and the host
will read it and know someone wants to take control.
--!>
var o:Object = new Object;
o.person_int = person_int; // Id for new host
so_primary.setProperty(so_primary_name,o); // Changes remote shared
object
pubVideo.source = null; // stop looking at the host's feed
4. Host is Told Change is Requested:
<!-- The eventHandler notifies host of change. When the host
determines someone is taking control, they stop publishing video.
--!>
private function gotParticipantSO(e:SyncEvent):void {
pubVideo.attachCamera(null);
pubVideo.source=null;
nsPublish.attachCamera(null);
nsPublish.attachAudio(null);
nsPublish.close();
}
<!-- Now we wait until nsPublish's status event handler tells us when
we've unpublished. Then the user is notified they can take over
through the remote shared object
--!>
private function networkStatus(event:NetStatusEvent):void {
var o:Object = new Object;
switch (event.info.code.toString() ) {
case "NetStream.Unpublish.Success":
so_primary.setProperty(so_primary_name,o); //tell user I've quit so
they can publish
pubVideo.source = rtmpPath + "/" + rtmpSession + "/LS";
// start looking at the new host (user)
}
5. User Gets Notified They Have Control:
(and not the right picture in their video display!)
<!--
This is the same routine as was used when the host initially connected
--!>
if(nc.connected){
nsPublish = new NetStream(nc); //Initializing NetStream
nsPublish.attachAudio(Microphone.getMicrophone());
nsPublish.publish("LS","live");
cam = Camera.getCamera();
if (cam != null) {
nsPublish.attachCamera(cam); // THIS SEEN ON ALL OTHER CONNECTIONS
pubVideo.attachCamera(cam); // THIS NOT WORKING, STILL PICTURE!?
addChild(pubVideo);
}
}
<mx:VideoDisplay width="192" height="142" id="pubVideo" live="true"/>
So, the stream is really being published as everyone can see and hear
the new host. It's just on the new host's display they are seeing a
still picture of the first host. Seems simple, but...