|
|
@ -19267,16 +19267,17 @@ const createEpisodesView = (playController, plex, data) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const episodeInteractiveArea = document.createElement('div');
|
|
|
|
const episodeInteractiveArea = document.createElement('div');
|
|
|
|
episodeInteractiveArea.className = 'interactiveArea';
|
|
|
|
episodeInteractiveArea.className = 'interactiveArea';
|
|
|
|
const episodePlayButton = document.createElement('button');
|
|
|
|
if (playController) {
|
|
|
|
episodePlayButton.name = 'playButton';
|
|
|
|
const episodePlayButton = playController.getPlayButton(data.type);
|
|
|
|
episodePlayButton.addEventListener('click', episodeEvent => {
|
|
|
|
episodePlayButton.addEventListener('click', (episodeEvent) => {
|
|
|
|
episodeEvent.stopPropagation();
|
|
|
|
episodeEvent.stopPropagation();
|
|
|
|
playController.play(data, true);
|
|
|
|
playController.play(data, true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (!playController.isPlaySupported(data)) {
|
|
|
|
if (playController.isPlaySupported(data)) {
|
|
|
|
episodePlayButton.classList.add('disabled');
|
|
|
|
episodePlayButton.classList.remove('disabled');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
episodeInteractiveArea.append(episodePlayButton);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
episodeInteractiveArea.append(episodePlayButton);
|
|
|
|
|
|
|
|
episodeElem.append(episodeInteractiveArea);
|
|
|
|
episodeElem.append(episodeInteractiveArea);
|
|
|
|
episodeContainer.append(episodeElem);
|
|
|
|
episodeContainer.append(episodeElem);
|
|
|
|
const episodeTitleElem = document.createElement('div');
|
|
|
|
const episodeTitleElem = document.createElement('div');
|
|
|
@ -19328,6 +19329,7 @@ const isScrolledIntoView = (elem) => {
|
|
|
|
|
|
|
|
|
|
|
|
class PlayController {
|
|
|
|
class PlayController {
|
|
|
|
constructor(hass, plex, entity, runBefore, runAfter, libraryName) {
|
|
|
|
constructor(hass, plex, entity, runBefore, runAfter, libraryName) {
|
|
|
|
|
|
|
|
this.playButtons = [];
|
|
|
|
this.readyPlayersForType = {};
|
|
|
|
this.readyPlayersForType = {};
|
|
|
|
this.entityStates = {};
|
|
|
|
this.entityStates = {};
|
|
|
|
this.plexPlayerEntity = '';
|
|
|
|
this.plexPlayerEntity = '';
|
|
|
@ -19682,6 +19684,14 @@ class PlayController {
|
|
|
|
command
|
|
|
|
command
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
this.getPlayButton = (mediaType) => {
|
|
|
|
|
|
|
|
const playButton = document.createElement('button');
|
|
|
|
|
|
|
|
playButton.name = 'playButton';
|
|
|
|
|
|
|
|
playButton.classList.add('disabled');
|
|
|
|
|
|
|
|
playButton.setAttribute('data-mediaType', mediaType);
|
|
|
|
|
|
|
|
this.playButtons.push(playButton);
|
|
|
|
|
|
|
|
return playButton;
|
|
|
|
|
|
|
|
};
|
|
|
|
this.refreshAvailableServicesPeriodically = async () => {
|
|
|
|
this.refreshAvailableServicesPeriodically = async () => {
|
|
|
|
const sleep = async (ms) => {
|
|
|
|
const sleep = async (ms) => {
|
|
|
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
|
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
|
@ -19696,7 +19706,15 @@ class PlayController {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.getPlayService(mockData, true);
|
|
|
|
this.getPlayService(mockData, true);
|
|
|
|
if (!lodash.isEqual(previousReadyPlayersForType, this.readyPlayersForType)) {
|
|
|
|
if (!lodash.isEqual(previousReadyPlayersForType, this.readyPlayersForType)) {
|
|
|
|
console.log('CHANGED');
|
|
|
|
lodash.forEach(this.playButtons, playButton => {
|
|
|
|
|
|
|
|
const playButtonType = playButton.getAttribute('data-mediaType');
|
|
|
|
|
|
|
|
if (lodash.isEmpty(this.readyPlayersForType[playButtonType])) {
|
|
|
|
|
|
|
|
playButton.classList.add('disabled');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
playButton.classList.remove('disabled');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// eslint-disable-next-line no-await-in-loop
|
|
|
|
// eslint-disable-next-line no-await-in-loop
|
|
|
@ -22339,17 +22357,19 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
toViewElem.innerHTML = (seasonData.leafCount - seasonData.viewedLeafCount).toString();
|
|
|
|
toViewElem.innerHTML = (seasonData.leafCount - seasonData.viewedLeafCount).toString();
|
|
|
|
interactiveArea.appendChild(toViewElem);
|
|
|
|
interactiveArea.appendChild(toViewElem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const playButton = this.getPlayButton();
|
|
|
|
if (this.playController) {
|
|
|
|
if (this.playController && this.playController.isPlaySupported(seasonData)) {
|
|
|
|
const playButton = this.playController.getPlayButton(seasonData.type);
|
|
|
|
playButton.classList.remove('disabled');
|
|
|
|
if (this.playController.isPlaySupported(seasonData)) {
|
|
|
|
}
|
|
|
|
playButton.classList.remove('disabled');
|
|
|
|
playButton.addEventListener('click', event => {
|
|
|
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
|
|
if (this.plex && this.playController) {
|
|
|
|
|
|
|
|
this.playController.play(seasonData, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
playButton.addEventListener('click', event => {
|
|
|
|
interactiveArea.append(playButton);
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
|
|
if (this.plex && this.playController) {
|
|
|
|
|
|
|
|
this.playController.play(seasonData, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
interactiveArea.append(playButton);
|
|
|
|
|
|
|
|
}
|
|
|
|
seasonElem.append(interactiveArea);
|
|
|
|
seasonElem.append(interactiveArea);
|
|
|
|
seasonContainer.append(seasonElem);
|
|
|
|
seasonContainer.append(seasonElem);
|
|
|
|
const seasonTitleElem = document.createElement('div');
|
|
|
|
const seasonTitleElem = document.createElement('div');
|
|
|
@ -22635,7 +22655,6 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
this.activeMovieElemData = data;
|
|
|
|
this.activeMovieElemData = data;
|
|
|
|
this.activateMovieElem(movieElem);
|
|
|
|
this.activateMovieElem(movieElem);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
const playButton = this.getPlayButton();
|
|
|
|
|
|
|
|
const interactiveArea = document.createElement('div');
|
|
|
|
const interactiveArea = document.createElement('div');
|
|
|
|
if (!(data.viewCount && data.viewCount > 0) && data.type === 'movie') {
|
|
|
|
if (!(data.viewCount && data.viewCount > 0) && data.type === 'movie') {
|
|
|
|
const toViewElem = document.createElement('div');
|
|
|
|
const toViewElem = document.createElement('div');
|
|
|
@ -22655,20 +22674,23 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
interactiveArea.appendChild(toViewElem);
|
|
|
|
interactiveArea.appendChild(toViewElem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
interactiveArea.className = 'interactiveArea';
|
|
|
|
interactiveArea.className = 'interactiveArea';
|
|
|
|
if (this.playController && this.playController.isPlaySupported(data)) {
|
|
|
|
if (this.playController) {
|
|
|
|
playButton.classList.remove('disabled');
|
|
|
|
const playButton = this.playController.getPlayButton(data.type);
|
|
|
|
|
|
|
|
if (this.playController.isPlaySupported(data)) {
|
|
|
|
|
|
|
|
playButton.classList.remove('disabled');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
interactiveArea.append(playButton);
|
|
|
|
|
|
|
|
clickHandler(playButton, (event) => {
|
|
|
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
|
|
if (this.hassObj && this.playController) {
|
|
|
|
|
|
|
|
this.playController.play(data, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, (event) => {
|
|
|
|
|
|
|
|
console.log('Play version... will be here!');
|
|
|
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
interactiveArea.append(playButton);
|
|
|
|
|
|
|
|
movieElem.append(interactiveArea);
|
|
|
|
movieElem.append(interactiveArea);
|
|
|
|
clickHandler(playButton, (event) => {
|
|
|
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
|
|
if (this.hassObj && this.playController) {
|
|
|
|
|
|
|
|
this.playController.play(data, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, (event) => {
|
|
|
|
|
|
|
|
console.log('Play version... will be here!');
|
|
|
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
const titleElem = document.createElement('div');
|
|
|
|
const titleElem = document.createElement('div');
|
|
|
|
if (lodash.isEqual(data.type, 'episode')) {
|
|
|
|
if (lodash.isEqual(data.type, 'episode')) {
|
|
|
|
titleElem.innerHTML = escapeHtml(data.grandparentTitle);
|
|
|
|
titleElem.innerHTML = escapeHtml(data.grandparentTitle);
|
|
|
@ -22712,12 +22734,6 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
// this.appendChild(style);
|
|
|
|
// this.appendChild(style);
|
|
|
|
return `<style>${style.innerHTML}</style>`;
|
|
|
|
return `<style>${style.innerHTML}</style>`;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.getPlayButton = () => {
|
|
|
|
|
|
|
|
const playButton = document.createElement('button');
|
|
|
|
|
|
|
|
playButton.name = 'playButton';
|
|
|
|
|
|
|
|
playButton.classList.add('disabled');
|
|
|
|
|
|
|
|
return playButton;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
this.setConfig = (config) => {
|
|
|
|
this.setConfig = (config) => {
|
|
|
|
this.plexProtocol = 'http';
|
|
|
|
this.plexProtocol = 'http';
|
|
|
|
if (!config.ip) {
|
|
|
|
if (!config.ip) {
|
|
|
|