Im working on an android application where multiple user subscribe to my stream published from android device. What i want to pull off is, when i click the video of a certain subscriber, all the subscriber(user) will then subscribe to his/her stream rather than mine. if there is any article or code to suggest me, please do so.
1 Answers
I don't have a sample to point to but I can tell you how I would solve this.
You will need to communicate to everyone in the Session which stream to subscribe to. You can use the signal API in opentok to do this by passing a streamId along. Then when each participant receives that signal they can lookup the corresponding stream and subscribe to it. You will need to make sure that every time a new person joins you also send them a signal saying which stream to subscribe to. You can do this by listening for the connectionCreated event.
If only one participant is allowed to tell everyone who to subscribe to then you might want to have a look at the connection data property of tokens. Then you can add eg. 'admin' as the connection data and then when you receive the signals make sure that they are coming from someone that has 'admin' as their connection data.

- 1,517
- 7
- 12
-
Can you tell me , how do i make sure that everyone in the session subscribes to a particular stream from a particular person? – Ribesh Mhrzn Feb 07 '18 at 04:29
-
When each participant the signal from admin, how do i lookup the corresponding stream and subscribe to it? – Ribesh Mhrzn Feb 07 '18 at 04:45
-
You will need to keep track of the list of streams yourself. So listen for the streamCreated and streamDestroyed events and add/remove them to your own data structure. Then when you receive a signal you can go through and look up the Stream that goes with the streamId. – Adam Ullman Feb 07 '18 at 05:44
-
After Sending the streamID to all the clients, what methods should i use to subscribe to that stream as the streamID is a string and the API requires stream to build a subscriber. In other words , how do i use the streamId to subscribe to that stream? – Ribesh Mhrzn Feb 09 '18 at 07:54
-
That's what I meant about keeping track of the list of streams yourself. So you could use eg. a HashMap with the key being the streamId and the value being the stream object. Then you can look up that stream object and use the subscribe method. – Adam Ullman Feb 13 '18 at 01:06