mirror of https://github.com/OpenVidu/openvidu.git
openvidu-components: Fixed bug replacing the screen track
parent
948a64c551
commit
ad06e2239b
|
@ -153,6 +153,7 @@ export class OpenViduService {
|
||||||
if (hasVideoDevices || hasAudioDevices) {
|
if (hasVideoDevices || hasAudioDevices) {
|
||||||
const publisher = await this.initPublisher(targetElement, properties);
|
const publisher = await this.initPublisher(targetElement, properties);
|
||||||
this.participantService.setMyCameraPublisher(publisher);
|
this.participantService.setMyCameraPublisher(publisher);
|
||||||
|
this.participantService.updateParticipantMediaStatus();
|
||||||
return publisher;
|
return publisher;
|
||||||
} else {
|
} else {
|
||||||
this.participantService.setMyCameraPublisher(null);
|
this.participantService.setMyCameraPublisher(null);
|
||||||
|
@ -298,7 +299,6 @@ export class OpenViduService {
|
||||||
// Replace video track
|
// Replace video track
|
||||||
const videoTrack: MediaStreamTrack = mediaStream.getVideoTracks()[0];
|
const videoTrack: MediaStreamTrack = mediaStream.getVideoTracks()[0];
|
||||||
await this.participantService.getMyCameraPublisher().replaceTrack(videoTrack);
|
await this.participantService.getMyCameraPublisher().replaceTrack(videoTrack);
|
||||||
|
|
||||||
} else if (isReplacingAudio) {
|
} else if (isReplacingAudio) {
|
||||||
if (isFirefoxPlatform) {
|
if (isFirefoxPlatform) {
|
||||||
// Firefox throw an exception trying to get a new MediaStreamTrack if the older one is not stopped
|
// Firefox throw an exception trying to get a new MediaStreamTrack if the older one is not stopped
|
||||||
|
@ -311,17 +311,21 @@ export class OpenViduService {
|
||||||
await this.participantService.getMyCameraPublisher().replaceTrack(audioTrack);
|
await this.participantService.getMyCameraPublisher().replaceTrack(audioTrack);
|
||||||
}
|
}
|
||||||
} else if (videoType === VideoType.SCREEN) {
|
} else if (videoType === VideoType.SCREEN) {
|
||||||
const newScreenMediaStream = await this.OVScreen.getUserMedia(props);
|
let newScreenMediaStream;
|
||||||
// this.stopTracks(this.screenMediaStream);
|
try {
|
||||||
// this.screenMediaStream = newScreenMediaStream;
|
newScreenMediaStream = await this.OVScreen.getUserMedia(props);
|
||||||
await this.participantService.getMyScreenPublisher().replaceTrack(newScreenMediaStream.getVideoTracks()[0]);
|
this.participantService.getMyScreenPublisher().stream.getMediaStream().getVideoTracks()[0].stop();
|
||||||
|
await this.participantService.getMyScreenPublisher().replaceTrack(newScreenMediaStream.getVideoTracks()[0]);
|
||||||
|
} catch (error) {
|
||||||
|
this.log.w('Cannot create the new MediaStream', error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.log.e('Error replacing track ', error);
|
this.log.e('Error replacing track ', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async createMediaStream(pp: PublisherProperties): Promise<MediaStream>{
|
private async createMediaStream(pp: PublisherProperties): Promise<MediaStream> {
|
||||||
let mediaStream: MediaStream;
|
let mediaStream: MediaStream;
|
||||||
const isFirefoxPlatform = this.platformService.isFirefox();
|
const isFirefoxPlatform = this.platformService.isFirefox();
|
||||||
const isReplacingAudio = !!pp.audioSource;
|
const isReplacingAudio = !!pp.audioSource;
|
||||||
|
|
Loading…
Reference in New Issue