Reputation: 113
I am creating an app where I want a specific stream to be shown big on another page. There will be one page with all the streams (subscriptions) and one page which will show a SPECIFIC stream on the whole screen.
I got the first two steps working, the last step is a problem. I somehow need to fetch a stream object by the given streamId. Is this possible? OR is there another way to achieve this?
Upvotes: 1
Views: 673
Reputation: 2092
You might not even need a database for what you are trying to do. Simply connect both pages (specific stream and all streams) to the same sessionId. You can put streamId in your url as a parameter like this: ?streamId=1343-thneue...
In your streamCreated event, simply check the stream.streamId in your callback function with your url streamId. If they match, then call session.subscribe on that stream object.
Upvotes: 0
Reputation: 585
I dont know if this is the correct way to do it but you can add all the stream objects in an array:
var streamContainer = [];
session.on("streamCreated", streamCreatedHandler);
streamCreatedHandler = function(e) {
streamContainer.push(e.stream)
}
and when your ID gets fetched unsubscribe from current, iterate over the array and subscribe to the new stream:
for(var i = 0; i < streamContainer.length; i++) {
if(streamContainer[i].id == dbStreamId) {
session.subscribe(streamContainer[i], 'DOMELEMENT', {options});
}
}
Upvotes: 1