Closed JanNorden closed 7 years ago
Hi @JanNorden, this is an expected behaviour. If you do sendStream()
, you invoke getUserMedia()
again to retrieve a new camera Stream, in which you have to stop the current camera Stream to start the new camera Stream with the new settings provided in sendStream()
.
May I know how you are configuring your demo?
Why is the second streamEnded expected? the first one closes the original stream, but the second one?
BTW the html was messed up when I pasted it, so I tried dragging the files. They seemed to drop, but I see no indication that there are attached files.
Could you check if mediaAccessSuccess
was triggered?
Hi @JanNorden, you might try pasting the javascript code only here.
var skylink = new Skylink();
skylink.on('incomingStream', function(_peerId, stream) { var vid = document.getElementById('myvideo'); attachMediaStream(vid, stream); vid.style.display = 'block'; console.log('incomingStream'); });
skylink.on('streamEnded', function() { console.log('streamEnded'); var vid = document.getElementById('myvideo'); vid.style.display = 'none'; });
skylink.init({ apiKey: '3540d10d-1355-4bc8-9152-665c661f2879' }, () => { skylink.joinRoom( 'room1', { audio: false, video: false });});
function sendStream() { skylink.sendStream({ audio: {mute: true}, video: {resolution: {height: 240, width: 320 }} }, () => {}) }
The log or the second call so StartStream after adding mediaAcessSuccess is:
chrome: {"audio":{},"video":{"mandatory":{"maxWidth":320,"maxHeight":240}}} streamEnded mediaAccessSuccess incomingStream streamEnded
Here is the HTML as well:
`
<script src="//cdn.temasys.com.sg/skylink/skylinkjs/0.6.15/skylink.complete.js"></script>
<!--<script src="../firecloud/client/site//share/files/node_modules/skylinkjs/publish/skylink.complete.min.js"></script>-->
<script src="code.js"></script>
`
Hi @JanNorden, could you do the following to your code? I would like to check if the events are triggered correctly.
var skylink = new Skylink();
// Set log level
skylink.setLogLevel(skylink.LOG_LEVEL.DEBUG);
// Check if "mediaAccessSuccess" is triggered
skylink.on('mediaAccessSuccess', function (stream) {
console.log("Stream retrieved", stream.id);
});
// Check if "mediaAccessStopped" is triggered
skylink.on('mediaAccessStopped', function (stream) {
console.log("Stream stopped", stream.id);
});
skylink.on('incomingStream', function(_peerId, stream) {
console.log("Stream sent", stream.id);
var vid = document.getElementById('myvideo');
attachMediaStream(vid, stream);
vid.style.display = 'block';
console.log('incomingStream');
});
skylink.on('streamEnded', function(_peerId, _peerInfo, _isSelf, _isScreensharing, streamId) {
console.log("Stream that has ended", streamId);
console.log('streamEnded');
var vid = document.getElementById('myvideo');
vid.style.display = 'none';
});
skylink.init({
apiKey: '3540d10d-1355-4bc8-9152-665c661f2879'
}, () => { skylink.joinRoom(
'room1', {
audio: false,
video: false
});});
function sendStream() {
skylink.sendStream({
audio: {mute: true},
video: {resolution: {height: 240, width: 320 }}
}, () => {})
}
Can't you just run my example? Log get's kind of long.
skylink.complete.js:18464 SkylinkJS - <
skylink.complete.js:18462 SkylinkJS [zx8Ovc2LIaHghbw2AAR4] - <
skylink.complete.js:18462 SkylinkJS [KwCTxKkpdHGd0Gf9AAoh] - <
And without the logging:
chrome: {"audio":{},"video":{"mandatory":{"maxWidth":320,"maxHeight":240}}} code.js:24 Stream stopped undefined code.js:11 streamEnded code.js:19 Stream retrieved f45j2ijiyWkGfU0zS5HiFMFqbPTAoRmeLfqB code.js:7 incomingStream code.js:24 Stream stopped undefined code.js:11 streamEnded
Note that the stream isn't actually stopped. There is just an extra incorrect event.
Hi @JanNorden, verified. Thanks for the bug report. Yes, it is just extra incorrect events being trigger if you log the streamId
above. For now, I would suggest to identify streams with the stream.id
as a proper workaround as documented which should work for your case.
skylink.on('incomingStream', function (_peerId, stream) {
console.log("stream ID ->", stream.id);
});
skylink.on('streamEnded', function (_peerId, peerInfo, isSelf, isScreenSharing, streamId) {
console.log("stream ID ->", streamId);
});
Hi @JanNorden, this issue has been resolved in the 0.6.16
release version and hence I'm closing this ticket for now. If this issue persists, please feel free to re-open this ticket.
If you do a sendStream() on a running stream you will get the event sequence:
streamEnded incomingStream streamEnded
The following example illustrates the problem (press the sendStream button twice, the first time the webcam will be shown, the second time it won't, the events are shown in the console log).
Changing the script tag in index.html to 0.6.14 shows that this was not the case in 0.6.14
BTW, it would be nice if you have a free key that would work for the jsfiddle domain, then examples could be posted there.