Fix: Fullscreen trailer on safari, ie11 and ios devices

pull/16/head
Juraj Nyíri 3 years ago
parent c141521dee
commit 1914d62689

@ -19790,6 +19790,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
if (!this.detailsShown && if (!this.detailsShown &&
window.innerHeight + window.scrollY > height + getOffset(this.content).top - 300 && window.innerHeight + window.scrollY > height + getOffset(this.content).top - 300 &&
this.renderedItems > 0) { this.renderedItems > 0) {
console.log('renderNewElementsIfNeeded');
this.maxRenderCount = this.renderedItems - 1 + this.columnsCount * (loadAdditionalRowsCount * 2); this.maxRenderCount = this.renderedItems - 1 + this.columnsCount * (loadAdditionalRowsCount * 2);
this.renderMovieElems(); this.renderMovieElems();
this.calculatePositions(); this.calculatePositions();
@ -19829,7 +19830,14 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.previousPositions = []; this.previousPositions = [];
// todo: find a better way to detect resize... // todo: find a better way to detect resize...
setInterval(() => { setInterval(() => {
if (this.movieElems.length > 0) { const videoPlayer = this.getElementsByClassName('videoPlayer')[0];
let isFullScreen = false;
if (videoPlayer.children.length > 0) {
const video = videoPlayer.children[0];
isFullScreen =
video.offsetWidth > this.getElementsByClassName('searchContainer')[0].offsetWidth;
}
if (this.movieElems.length > 0 && !isFullScreen) {
let renderNeeded = false; let renderNeeded = false;
if (this.previousPositions.length === 0) { if (this.previousPositions.length === 0) {
for (let i = 0; i < this.movieElems.length; i += 1) { for (let i = 0; i < this.movieElems.length; i += 1) {
@ -19853,7 +19861,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.contentBGHeight = getHeight(contentbg[0]); this.contentBGHeight = getHeight(contentbg[0]);
} }
} }
}, 100); }, 250);
this.renderPage(); this.renderPage();
}; };
this.searchInput = () => { this.searchInput = () => {
@ -19971,8 +19979,16 @@ class PlexMeetsHomeAssistant extends HTMLElement {
if (this.videoElem) { if (this.videoElem) {
const videoPlayer = this.getElementsByClassName('videoPlayer')[0]; const videoPlayer = this.getElementsByClassName('videoPlayer')[0];
const video = videoPlayer.children[0]; const video = videoPlayer.children[0];
if (video.requestFullscreen) {
video.requestFullscreen(); video.requestFullscreen();
} }
else if (video.webkitRequestFullscreen) {
video.webkitRequestFullscreen();
}
else if (video.msRequestFullscreen) {
video.msRequestFullscreen();
}
}
}); });
this.seasonsElem = document.createElement('div'); this.seasonsElem = document.createElement('div');
this.seasonsElem.className = 'seasons'; this.seasonsElem.className = 'seasons';

@ -122,6 +122,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
window.innerHeight + window.scrollY > height + getOffset(this.content).top - 300 && window.innerHeight + window.scrollY > height + getOffset(this.content).top - 300 &&
this.renderedItems > 0 this.renderedItems > 0
) { ) {
console.log('renderNewElementsIfNeeded');
this.maxRenderCount = this.renderedItems - 1 + this.columnsCount * (loadAdditionalRowsCount * 2); this.maxRenderCount = this.renderedItems - 1 + this.columnsCount * (loadAdditionalRowsCount * 2);
this.renderMovieElems(); this.renderMovieElems();
@ -165,7 +166,15 @@ class PlexMeetsHomeAssistant extends HTMLElement {
// todo: find a better way to detect resize... // todo: find a better way to detect resize...
setInterval(() => { setInterval(() => {
if (this.movieElems.length > 0) { const videoPlayer = this.getElementsByClassName('videoPlayer')[0] as HTMLElement;
let isFullScreen = false;
if (videoPlayer.children.length > 0) {
const video = videoPlayer.children[0] as any;
isFullScreen =
video.offsetWidth > (this.getElementsByClassName('searchContainer')[0] as HTMLElement).offsetWidth;
}
if (this.movieElems.length > 0 && !isFullScreen) {
let renderNeeded = false; let renderNeeded = false;
if (this.previousPositions.length === 0) { if (this.previousPositions.length === 0) {
for (let i = 0; i < this.movieElems.length; i += 1) { for (let i = 0; i < this.movieElems.length; i += 1) {
@ -191,7 +200,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.contentBGHeight = getHeight(contentbg[0] as HTMLElement); this.contentBGHeight = getHeight(contentbg[0] as HTMLElement);
} }
} }
}, 100); }, 250);
this.renderPage(); this.renderPage();
}; };
@ -323,8 +332,14 @@ class PlexMeetsHomeAssistant extends HTMLElement {
fullscreenTrailer.addEventListener('click', () => { fullscreenTrailer.addEventListener('click', () => {
if (this.videoElem) { if (this.videoElem) {
const videoPlayer = this.getElementsByClassName('videoPlayer')[0] as HTMLElement; const videoPlayer = this.getElementsByClassName('videoPlayer')[0] as HTMLElement;
const video = videoPlayer.children[0] as HTMLVideoElement; const video = videoPlayer.children[0] as any;
if (video.requestFullscreen) {
video.requestFullscreen(); video.requestFullscreen();
} else if (video.webkitRequestFullscreen) {
video.webkitRequestFullscreen();
} else if (video.msRequestFullscreen) {
video.msRequestFullscreen();
}
} }
}); });

Loading…
Cancel
Save