mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: improve video mirroring logic
parent
905b7fe281
commit
85b6496ba0
|
@ -414,17 +414,17 @@ export class StreamManager extends EventDispatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.remote) {
|
if (this.remote && this.isMirroredVideo(video)) {
|
||||||
// Do not mirror remote video.
|
// Remote video associated to a previously mirrored video element
|
||||||
// Remove the mirror if this video was currently associated with a local mirrored video.
|
|
||||||
this.removeMirrorVideo(video);
|
this.removeMirrorVideo(video);
|
||||||
}
|
} else if (!this.stream.displayMyRemote()) {
|
||||||
else if (!this.stream.displayMyRemote()) {
|
// Local video
|
||||||
video.muted = true;
|
video.muted = true;
|
||||||
if (video.style.transform === 'rotateY(180deg)' && !this.stream.outboundStreamOpts.publisherProperties.mirror) {
|
if (this.isMirroredVideo(video) && !this.stream.outboundStreamOpts.publisherProperties.mirror) {
|
||||||
// If the video was already rotated and now is set to not mirror
|
// If the video was already rotated and now is set to not mirror
|
||||||
this.removeMirrorVideo(video);
|
this.removeMirrorVideo(video);
|
||||||
} else if (this.stream.outboundStreamOpts.publisherProperties.mirror && !this.stream.isSendScreen()) {
|
} else if (this.stream.outboundStreamOpts.publisherProperties.mirror && !this.stream.isSendScreen()) {
|
||||||
|
// If the video is now set to mirror and is not screen share
|
||||||
this.mirrorVideo(video);
|
this.mirrorVideo(video);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -536,18 +536,22 @@ export class StreamManager extends EventDispatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private mirrorVideo(video): void {
|
private mirrorVideo(video: HTMLVideoElement): void {
|
||||||
if (!platform.isIonicIos()) {
|
if (!platform.isIonicIos()) {
|
||||||
video.style.transform = 'rotateY(180deg)';
|
video.style.transform = 'rotateY(180deg)';
|
||||||
video.style.webkitTransform = 'rotateY(180deg)';
|
video.style.webkitTransform = 'rotateY(180deg)';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private removeMirrorVideo(video): void {
|
private removeMirrorVideo(video: HTMLVideoElement): void {
|
||||||
video.style.transform = 'unset';
|
video.style.transform = 'unset';
|
||||||
video.style.webkitTransform = 'unset';
|
video.style.webkitTransform = 'unset';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isMirroredVideo(video: HTMLVideoElement): boolean {
|
||||||
|
return video.style.transform === 'rotateY(180deg)' || video.style.webkitTransform === 'rotateY(180deg)';
|
||||||
|
}
|
||||||
|
|
||||||
private activateStreamPlayingEventExceptionTimeout() {
|
private activateStreamPlayingEventExceptionTimeout() {
|
||||||
if (!this.remote) {
|
if (!this.remote) {
|
||||||
// ExceptionEvent NO_STREAM_PLAYING_EVENT is only for subscribers
|
// ExceptionEvent NO_STREAM_PLAYING_EVENT is only for subscribers
|
||||||
|
|
Loading…
Reference in New Issue