Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to detect webcam streams without receiving ones

Avatar

Level 2

Hi!
I am looking a way to know when user(any user in the room/group) started to publish his webcam and stopped.
I've tried to add listener to StreamManager

            protected function cameraview_initializeHandler(event:FlexEvent):void{
                this._connectionSession.streamManager.addEventListener(StreamEvent.STREAM_RECEIVE, this.streamReceivedHandler);
            }
            protected function streamReceivedHandler(event:StreamEvent):void{
               trace('stream received', event.name, event.streamDescriptor.groupName, event.streamDescriptor.streamPublisherID);
            }

And STREAM_RECEIVE called when another user started to publish, but event has groupName=null and streamPublisherID is NULL too.
I need this to give posibility to choose streams needed to play and lower bandwith.
I've tried to use WebcamSubsriber too, but it starts to display stream right when it is received.
What have i missed?

1 Accepted Solution

Avatar

Correct answer by
Level 10

You may be doing something wrong. Can you send me a small test code and where you are getting null so that I can run on my side and point any mistake or debug into it.

Thanks

Hironmay Basu

View solution in original post

6 Replies

Avatar

Level 10

Hi,

Though I am not sure if I understood your question correctly, but If you want to know when user started his publish and stop camera, he should listen to WebcamPublisher for STREAM_RECEIVE (for publishing) and STREAM_DELETE ( for stopping). And if you want to know for other user's , you should listen to similar event from WebcamSubscriber.

By default, the group is null , unless you have assigned any particular groupname to your publisher/subscriber component.

Hope this helps

Thanks

Hironmay Basu

Avatar

Level 2

Thanks for the reply!

I need to know streams of another users connected to group.

I've tried this with WebcamSubscriber and when another user starts publishing, my user receives STREAM_RECEIVE event and starts to play stream automatically. But before play stream(and create NetStream object and start to load my bandwith with webcam video) I need to know that stream is available and display popup with question like "Someone started webcam, do you want to see this?".

Avatar

Level 10

Oh ok. If you do not by default want to see the other user's stream, you should set initially the publisherIDs property in the WebcamSubscriber to an empty array( not just leave it as by default, it shows every stream). Now, let's say when you get a stream from an user by listening to StreamManager's STREAM_RECEIVE , then you would have to assign publisherIDs array to have that publisherID of the stream that you want to see and it will start showing that user's stream. You need to listen to StreamManager ( and not subscriber) in this case because the subscriber won't know beforehand whether it has to show that stream and won't dispatch the STREAM_RECEIVE event.

Thanks

Regards

Hironmay Basu

Avatar

Level 2

Yeah, I've tried this but when I am receiving this StreamEvent, how to get owners ID? When i traced event.streamDescriptor.streamPublisherID it showed NULL.

Avatar

Correct answer by
Level 10

You may be doing something wrong. Can you send me a small test code and where you are getting null so that I can run on my side and point any mistake or debug into it.

Thanks

Hironmay Basu