Audio-only also works if camera access is blocked but mic is allowed
This commit is contained in:
parent
ea78653374
commit
1754101d52
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -374,32 +374,46 @@ export class Stream {
|
||||
private requestCameraAccesAux(constraints, callback) {
|
||||
navigator.mediaDevices.getUserMedia(constraints)
|
||||
.then(userStream => {
|
||||
this.accessIsAllowed = true;
|
||||
this.accessIsDenied = false;
|
||||
this.ee.emitEvent('access-allowed-by-publisher');
|
||||
|
||||
if (userStream.getAudioTracks()[0] != null) {
|
||||
userStream.getAudioTracks()[0].enabled = this.sendAudio;
|
||||
}
|
||||
if (userStream.getVideoTracks()[0] != null) {
|
||||
userStream.getVideoTracks()[0].enabled = this.sendVideo;
|
||||
}
|
||||
|
||||
this.wrStream = userStream;
|
||||
this.emitSrcEvent(this.wrStream);
|
||||
|
||||
callback(undefined, this);
|
||||
this.cameraAccessSuccess(userStream, callback);
|
||||
})
|
||||
.catch(error => {
|
||||
this.accessIsDenied = true;
|
||||
this.accessIsAllowed = false;
|
||||
this.ee.emitEvent('access-denied-by-publisher');
|
||||
// Try to ask for microphone only
|
||||
navigator.mediaDevices.getUserMedia({ audio: true, video: false })
|
||||
.then(userStream => {
|
||||
constraints.video = false;
|
||||
this.sendVideo = false;
|
||||
this.audioOnly = true;
|
||||
this.cameraAccessSuccess(userStream, callback);
|
||||
})
|
||||
.catch(error => {
|
||||
this.accessIsDenied = true;
|
||||
this.accessIsAllowed = false;
|
||||
this.ee.emitEvent('access-denied-by-publisher');
|
||||
|
||||
console.error("Access denied", error);
|
||||
callback(error, this);
|
||||
console.error("Access denied", error);
|
||||
callback(error, this);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private cameraAccessSuccess(userStream, callback) {
|
||||
this.accessIsAllowed = true;
|
||||
this.accessIsDenied = false;
|
||||
this.ee.emitEvent('access-allowed-by-publisher');
|
||||
|
||||
if (userStream.getAudioTracks()[0] != null) {
|
||||
userStream.getAudioTracks()[0].enabled = this.sendAudio;
|
||||
}
|
||||
if (userStream.getVideoTracks()[0] != null) {
|
||||
userStream.getVideoTracks()[0].enabled = this.sendVideo;
|
||||
}
|
||||
|
||||
this.wrStream = userStream;
|
||||
this.emitSrcEvent(this.wrStream);
|
||||
|
||||
callback(undefined, this);
|
||||
}
|
||||
|
||||
private userMediaHasVideo(callback) {
|
||||
navigator.mediaDevices.enumerateDevices().then(function (mediaDevices) {
|
||||
var videoInput = mediaDevices.filter(function (deviceInfo) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user