Expand my Community achievements bar.

WebcamPublisher change event incorrect behavior?

Avatar

Level 4

When using a webcamPublisher and listening to the change event I only get an event fired when the camera starts publishing, but not when it stops.

changeevent
Event object type: flash.events.Event

Dispatched when the camera is accessed for publishing or is stopped.

If I use the isCameraPublishing event instead, then I will get an event fired when I stop or start the camera. 

isCameraPublishingevent
Event object type: flash.events.Event

Dispatched when the user's camera publishing state changes.

The only difficult part, and maybe this can be changed in the docs (or maybe I should just know better) is that this isCameraPublishing event needs to be setup like this: webPub.addEventListener("isCameraPublishing", webPubChange);  because in your code it is dispatched like this: dispatchEvent(new flash.events.Event("isCameraPublishing"));  Maybe I'm just lazy but I'm so used to using the class to define the event name that I expected to be able to do this at first webPub.addEventListener(flash.events.Event.isCameraPublishing, webPubChange);


Just reporting what looked like odd behavior to me.

-Eric

3 Replies

Avatar

Former Community Member

Hi,

For stopping, you need to listen to STREAM_DELETE event. You can look at player 9 source for reference. isCameraPublishing is only fired when camera starts.

Thanks

Hironmay Basu

Avatar

Level 4

isCameraPublishing fires when I do this webPub.stop(); is that not supposed

to happen?

Avatar

Former Community Member

Yes,

You can use that event to check webcamPub.isPublishing whether its publishing or not. That code is same for 9 and 10.

Thanks

Hironmay Basu