From c6288deb93e542d506e456930457630d1bb92042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Wed, 5 May 2021 18:08:00 +0200 Subject: [PATCH] Add: Play button for seasons --- dist/plex-meets-homeassistant.js | 17 +++++++++++++++-- src/plex-meets-homeassistant.ts | 19 +++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index ed97fc6..ed9323f 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -19477,8 +19477,20 @@ class PlexMeetsHomeAssistant extends HTMLElement { const seasonElem = document.createElement('div'); seasonElem.className = 'seasonElem'; seasonElem.style.width = `${CSS_STYLE.width}px`; - seasonElem.style.height = `${CSS_STYLE.height}px`; + seasonElem.style.height = `${CSS_STYLE.height - 3}px`; seasonElem.style.backgroundImage = `url('${thumbURL}')`; + const interactiveArea = document.createElement('div'); + interactiveArea.className = 'interactiveArea'; + const playButton = document.createElement('button'); + playButton.name = 'playButton'; + playButton.addEventListener('click', event => { + event.stopPropagation(); + if (this.plex && this.playController) { + this.playController.play(seasonData.key.split('/')[3]); + } + }); + interactiveArea.append(playButton); + seasonElem.append(interactiveArea); seasonContainer.append(seasonElem); const seasonTitleElem = document.createElement('div'); seasonTitleElem.className = 'seasonTitleElem'; @@ -19491,8 +19503,9 @@ class PlexMeetsHomeAssistant extends HTMLElement { seasonContainer.addEventListener('click', event => { event.stopPropagation(); (async () => { - if (this.plex) { + if (this.plex && this.playController) { console.log(seasonData); + // this.playController.play(seasonData.key.split('/')[3]); console.log(await this.plex.getLibraryData(seasonData.key.split('/')[3])); } })(); diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index af682d9..318ee06 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -320,9 +320,23 @@ class PlexMeetsHomeAssistant extends HTMLElement { const seasonElem = document.createElement('div'); seasonElem.className = 'seasonElem'; seasonElem.style.width = `${CSS_STYLE.width}px`; - seasonElem.style.height = `${CSS_STYLE.height}px`; + seasonElem.style.height = `${CSS_STYLE.height - 3}px`; seasonElem.style.backgroundImage = `url('${thumbURL}')`; + const interactiveArea = document.createElement('div'); + interactiveArea.className = 'interactiveArea'; + + const playButton = document.createElement('button'); + playButton.name = 'playButton'; + playButton.addEventListener('click', event => { + event.stopPropagation(); + if (this.plex && this.playController) { + this.playController.play(seasonData.key.split('/')[3]); + } + }); + + interactiveArea.append(playButton); + seasonElem.append(interactiveArea); seasonContainer.append(seasonElem); const seasonTitleElem = document.createElement('div'); @@ -338,8 +352,9 @@ class PlexMeetsHomeAssistant extends HTMLElement { seasonContainer.addEventListener('click', event => { event.stopPropagation(); (async (): Promise => { - if (this.plex) { + if (this.plex && this.playController) { console.log(seasonData); + // this.playController.play(seasonData.key.split('/')[3]); console.log(await this.plex.getLibraryData(seasonData.key.split('/')[3])); } })();