mirror of https://github.com/OpenVidu/openvidu.git
Only audio input now does not break getUserMedia process
parent
43cde8d44f
commit
a8509a1ec5
|
@ -6,6 +6,7 @@
|
||||||
"types": "lib/OpenVidu/index.d.ts",
|
"types": "lib/OpenVidu/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"browserify": "cd ts/OpenVidu && browserify Main.ts -p [ tsify ] --exclude kurento-browser-extensions --debug -o ../../static/js/OpenVidu.js -v",
|
"browserify": "cd ts/OpenVidu && browserify Main.ts -p [ tsify ] --exclude kurento-browser-extensions --debug -o ../../static/js/OpenVidu.js -v",
|
||||||
|
"browserify-prod": "cd ts/OpenVidu && browserify --debug Main.ts -p [ tsify ] --exclude kurento-browser-extensions | uglifyjs -c > ../../static/js/OpenVidu.js",
|
||||||
"updatetsc": "cd ts/OpenViduInternal && tsc && cd ../OpenVidu && tsc",
|
"updatetsc": "cd ts/OpenViduInternal && tsc && cd ../OpenVidu && tsc",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"prepublish": "cd ts && tsc",
|
"prepublish": "cd ts && tsc",
|
||||||
|
|
|
@ -244,6 +244,9 @@ export class Stream {
|
||||||
}
|
}
|
||||||
|
|
||||||
playOnlyVideo(parentElement, thumbnailId) {
|
playOnlyVideo(parentElement, thumbnailId) {
|
||||||
|
|
||||||
|
// TO-DO: check somehow if the stream is audio only, so the element created is <audio> instead of <video>
|
||||||
|
|
||||||
this.video = document.createElement('video');
|
this.video = document.createElement('video');
|
||||||
|
|
||||||
this.video.id = 'native-video-' + this.getId();
|
this.video.id = 'native-video-' + this.getId();
|
||||||
|
@ -339,7 +342,7 @@ export class Stream {
|
||||||
|
|
||||||
let constraints = this.mediaConstraints;
|
let constraints = this.mediaConstraints;
|
||||||
|
|
||||||
let constraints2 = {
|
/*let constraints2 = {
|
||||||
audio: true,
|
audio: true,
|
||||||
video: {
|
video: {
|
||||||
width: {
|
width: {
|
||||||
|
@ -349,16 +352,32 @@ export class Stream {
|
||||||
ideal: 15
|
ideal: 15
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};*/
|
||||||
|
|
||||||
|
this.userMediaHasVideo((hasVideo) => {
|
||||||
|
if (!hasVideo) {
|
||||||
|
constraints.video = false;
|
||||||
|
this.sendVideo = false;
|
||||||
|
this.requestCameraAccesAux(constraints, callback);
|
||||||
|
} else {
|
||||||
|
this.requestCameraAccesAux(constraints, callback);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private requestCameraAccesAux(constraints, callback) {
|
||||||
navigator.mediaDevices.getUserMedia(constraints)
|
navigator.mediaDevices.getUserMedia(constraints)
|
||||||
.then(userStream => {
|
.then(userStream => {
|
||||||
this.accessIsAllowed = true;
|
this.accessIsAllowed = true;
|
||||||
this.accessIsDenied = false;
|
this.accessIsDenied = false;
|
||||||
this.ee.emitEvent('access-allowed-by-publisher');
|
this.ee.emitEvent('access-allowed-by-publisher');
|
||||||
|
|
||||||
|
if (userStream.getAudioTracks()[0] != null) {
|
||||||
userStream.getAudioTracks()[0].enabled = this.sendAudio;
|
userStream.getAudioTracks()[0].enabled = this.sendAudio;
|
||||||
|
}
|
||||||
|
if (userStream.getVideoTracks()[0] != null) {
|
||||||
userStream.getVideoTracks()[0].enabled = this.sendVideo;
|
userStream.getVideoTracks()[0].enabled = this.sendVideo;
|
||||||
|
}
|
||||||
|
|
||||||
this.wrStream = userStream;
|
this.wrStream = userStream;
|
||||||
this.emitSrcEvent(this.wrStream);
|
this.emitSrcEvent(this.wrStream);
|
||||||
|
@ -375,6 +394,15 @@ export class Stream {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private userMediaHasVideo(callback) {
|
||||||
|
navigator.mediaDevices.enumerateDevices().then(function (mediaDevices) {
|
||||||
|
var videoInput = mediaDevices.filter(function (deviceInfo) {
|
||||||
|
return deviceInfo.kind === 'videoinput';
|
||||||
|
})[0];
|
||||||
|
callback(videoInput != null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
publishVideoCallback(error, sdpOfferParam, wp) {
|
publishVideoCallback(error, sdpOfferParam, wp) {
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|
Loading…
Reference in New Issue