Expand my Community achievements bar.

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
Former Community Member

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

Former Community Member

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

Former Community Member

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
Former Community Member

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

Avatar

Level 2

Yes, looks like so. Thanks for pointing me to this!

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----