mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: videoDimensions property support for Ionic
parent
5b4b34e254
commit
fef0b62ff0
|
@ -79,7 +79,7 @@ export class OpenVidu {
|
||||||
console.info("'OpenVidu' initialized");
|
console.info("'OpenVidu' initialized");
|
||||||
|
|
||||||
if (platform.os!!.family === 'iOS' || platform.os!!.family === 'Android') {
|
if (platform.os!!.family === 'iOS' || platform.os!!.family === 'Android') {
|
||||||
// Listen to orientationchange only on mobile browsers
|
// Listen to orientationchange only on mobile devices
|
||||||
(<any>window).onorientationchange = () => {
|
(<any>window).onorientationchange = () => {
|
||||||
this.publishers.forEach(publisher => {
|
this.publishers.forEach(publisher => {
|
||||||
if (!!publisher.stream && !!publisher.stream.hasVideo && !!publisher.stream.streamManager.videos[0]) {
|
if (!!publisher.stream && !!publisher.stream.hasVideo && !!publisher.stream.streamManager.videos[0]) {
|
||||||
|
|
|
@ -312,22 +312,42 @@ export class Publisher extends StreamManager {
|
||||||
if (!this.stream.isSendScreen()) {
|
if (!this.stream.isSendScreen()) {
|
||||||
|
|
||||||
if (platform['isIonicIos']) {
|
if (platform['isIonicIos']) {
|
||||||
// iOS Ionic. Limitation: cannot set videoDimensions, as the videoReference is not loaded if not added to DOM
|
// iOS Ionic. Limitation: cannot set videoDimensions directly, as the videoReference is not loaded
|
||||||
/*this.videoReference.onloadedmetadata = () => {
|
// if not added to DOM. Must add it to DOM and wait for videoWidth and videoHeight properties to be defined
|
||||||
|
|
||||||
|
this.videoReference.style.display = 'none';
|
||||||
|
document.body.appendChild(this.videoReference);
|
||||||
|
|
||||||
|
const videoDimensionsSet = () => {
|
||||||
this.stream.videoDimensions = {
|
this.stream.videoDimensions = {
|
||||||
width: this.videoReference.videoWidth,
|
width: this.videoReference.videoWidth,
|
||||||
height: this.videoReference.videoHeight
|
height: this.videoReference.videoHeight
|
||||||
};
|
};
|
||||||
};*/
|
this.stream.isLocalStreamReadyToPublish = true;
|
||||||
this.stream.isLocalStreamReadyToPublish = true;
|
this.stream.ee.emitEvent('stream-ready-to-publish', []);
|
||||||
this.stream.ee.emitEvent('stream-ready-to-publish', []);
|
document.body.removeChild(this.videoReference);
|
||||||
|
}
|
||||||
|
|
||||||
|
let interval;
|
||||||
|
this.videoReference.onloadedmetadata = () => {
|
||||||
|
if (this.videoReference.videoWidth === 0) {
|
||||||
|
interval = setInterval(() => {
|
||||||
|
if (this.videoReference.videoWidth !== 0) {
|
||||||
|
videoDimensionsSet();
|
||||||
|
clearInterval(interval);
|
||||||
|
}
|
||||||
|
}, 10);
|
||||||
|
} else {
|
||||||
|
videoDimensionsSet();
|
||||||
|
}
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
// Rest of platforms
|
// Rest of platforms
|
||||||
// With no screen share, video dimension can be set directly from MediaStream (getSettings)
|
// With no screen share, video dimension can be set directly from MediaStream (getSettings)
|
||||||
// Orientation must be checked for mobile devices (width and height are reversed)
|
// Orientation must be checked for mobile devices (width and height are reversed)
|
||||||
const { width, height } = mediaStream.getVideoTracks()[0].getSettings();
|
const { width, height } = mediaStream.getVideoTracks()[0].getSettings();
|
||||||
|
|
||||||
if (platform.name!!.toLowerCase().indexOf('mobile') !== -1 && (window.innerHeight > window.innerWidth)) {
|
if ((platform.os!!.family === 'iOS' || platform.os!!.family === 'Android') && (window.innerHeight > window.innerWidth)) {
|
||||||
// Mobile portrait mode
|
// Mobile portrait mode
|
||||||
this.stream.videoDimensions = {
|
this.stream.videoDimensions = {
|
||||||
width: height || 0,
|
width: height || 0,
|
||||||
|
|
|
@ -439,8 +439,10 @@ export class StreamManager implements EventDispatcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
private mirrorVideo(video): void {
|
private mirrorVideo(video): void {
|
||||||
video.style.transform = 'rotateY(180deg)';
|
if (!platform['isIonicIos']) {
|
||||||
video.style.webkitTransform = 'rotateY(180deg)';
|
video.style.transform = 'rotateY(180deg)';
|
||||||
|
video.style.webkitTransform = 'rotateY(180deg)';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private removeMirrorVideo(video): void {
|
private removeMirrorVideo(video): void {
|
||||||
|
|
Loading…
Reference in New Issue