Reputation: 31
I use Firefox v55.0.2
In documentation (https://developer.mozilla.org/en-US/docs/Web/API/Navigator/getUserMedia), after NavigatorUserMedia.getUserMedia() normally in successCallback i have a MediaStream but in my case i have LocalMediaStream.
I need to have MediaStreamTrack to give it at twilio.
This is my code :
$scope.testShareFirefox = function () {
var p = navigator.mediaDevices.getUserMedia({
video: {
mediaSource: 'screen',
width: 640,
height: 480
},
})
.then(function(stream) {
const screenLocalTrack = new twilio.Video.LocalVideoTrack(stream);
$scope.videoConf.room.localParticipant.addTrack(screenLocalTrack);
var video = document.createElement('video');
$('#test-share-screen').append(video);
video.srcObject = stream;
video.play();
})
.catch(function (err) {
console.log(err);
});
};
Thank you.
Upvotes: 1
Views: 259
Reputation: 31
I found the solution.
LocalMediaStream is Inheritance of MediaStream so we can use ".getTracks()"
This is the work solution :
$scope.testShareFirefox = function () {
navigator.mediaDevices.getUserMedia({
video: {
mediaSource: 'screen',
width: 640,
height: 480
},
})
.then(function(stream) {
stream.getTracks().forEach(function(track) {
$scope.videoConf.room.localParticipant.addTrack(track);
});
var video = document.createElement('video');
$('#test-share-screen').append(video);
video.srcObject = stream;
video.play();
var trackElements = document.querySelectorAll("track");
})
.catch(function (err) {
console.log(err);
});
};
Upvotes: 2