openvidu-browser: Fixed bug with audio only MediaStream

If a MediaStream is published with video track stopped  and a standard audio track, the video was not playing because the video track of subscriber was enabled. This track must be disabled for allowing play the video. 
Issue reference: https://openvidu.discourse.group/t/microphone-doesnt-work-correctly-on-web-from-a-mobile-device/4514
pull/797/head
csantosm 2023-03-31 14:37:22 +02:00
parent dade445ce7
commit ec807d3944
2 changed files with 5 additions and 1 deletions

View File

@ -992,6 +992,10 @@ export class Session extends EventDispatcher {
oldValue = stream.videoActive; oldValue = stream.videoActive;
event.newValue = event.newValue === 'true'; event.newValue = event.newValue === 'true';
stream.videoActive = event.newValue; stream.videoActive = event.newValue;
const videoTrack = stream.getMediaStream().getVideoTracks()[0];
if(!videoTrack.enabled && stream.videoActive){
videoTrack.enabled = true;
}
break; break;
case 'videoTrack': case 'videoTrack':
event.newValue = JSON.parse(event.newValue); event.newValue = JSON.parse(event.newValue);

View File

@ -1481,7 +1481,7 @@ export class Stream {
this.mediaStream.getAudioTracks()[0].enabled = enabled; this.mediaStream.getAudioTracks()[0].enabled = enabled;
} }
if (!!this.mediaStream.getVideoTracks()[0]) { if (!!this.mediaStream.getVideoTracks()[0]) {
const enabled = reconnect ? this.videoActive : !!(this.streamManager as Subscriber).properties.subscribeToVideo; const enabled = reconnect ? this.videoActive : !!this.videoActive && !!(this.streamManager as Subscriber).properties.subscribeToVideo;
this.mediaStream.getVideoTracks()[0].enabled = enabled; this.mediaStream.getVideoTracks()[0].enabled = enabled;
} }
} }