From b3eccce3494fee22347ceee4749639a765965c5b Mon Sep 17 00:00:00 2001 From: Josep Boix Requesens Date: Fri, 23 Feb 2024 13:16:50 +0100 Subject: [PATCH] chore(showcase): showcases for custom text tracks handling Introduces new showcases for integrators to benefit from the inclusion of custom text tracks in the pillarbox player (see srgssr/pillarbox-web#207). The showcases cover the implementation of: handling blocked segments, displaying current chapters, and managing time intervals. Code examples with ample comments have been added to provide developers with technical insight on how to integrate these features. --- package-lock.json | 8 +- package.json | 2 +- src/layout/content/showcase/showcase-page.js | 110 ++++++++++++++--- static/showcases/blocked-segment.html | 122 +++++++++++++++++++ static/showcases/blocked-segment.scss | 16 +++ static/showcases/chapters-showcase.scss | 43 +++++++ static/showcases/chapters.html | 120 ++++++++++++++++++ static/showcases/skip-credits.html | 107 ++++++++++++++++ static/showcases/skip-showcase.scss | 18 +++ static/showcases/static-showcase.scss | 2 +- 10 files changed, 523 insertions(+), 25 deletions(-) create mode 100644 static/showcases/blocked-segment.html create mode 100644 static/showcases/blocked-segment.scss create mode 100644 static/showcases/chapters-showcase.scss create mode 100644 static/showcases/chapters.html create mode 100644 static/showcases/skip-credits.html create mode 100644 static/showcases/skip-showcase.scss diff --git a/package-lock.json b/package-lock.json index a2f5bfe..93c5034 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "@srgssr/pillarbox-web": "^1.0.1", + "@srgssr/pillarbox-web": "^1.1.0", "highlight.js": "^11.9.0", "lit": "^3.1.1", "material-icons": "^1.13.12", @@ -1739,9 +1739,9 @@ ] }, "node_modules/@srgssr/pillarbox-web": { - "version": "1.0.1", - "resolved": "https://npm.pkg.github.com/download/@srgssr/pillarbox-web/1.0.1/66c4f497e5ee04d495fd2007110f9cfccf5bd437", - "integrity": "sha512-4MitZ6iMtYWLjWJUlTnFGz5Ap3v3zJ8AFUyH1+yQpJjdwfd4yUePv5umNkte20rpdMF0iBleMu4L7IPklsHOvA==", + "version": "1.1.0", + "resolved": "https://npm.pkg.github.com/download/@srgssr/pillarbox-web/1.1.0/3001926a2ae32e2996b39e690634e06e45252ebe", + "integrity": "sha512-hZG/iPyA4HK/Fzy7iPMxKFuc1Ed40mn7bUD05tVi185d3AsiXZbrcpRfRT7vJo/NeBAzFY+s3tQsOqI6aYMaDQ==", "license": "MIT", "dependencies": { "video.js": "^8.11.1", diff --git a/package.json b/package.json index 348b9fb..79c126f 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "vite": "^5.0.12" }, "dependencies": { - "@srgssr/pillarbox-web": "^1.0.1", + "@srgssr/pillarbox-web": "^1.1.0", "highlight.js": "^11.9.0", "lit": "^3.1.1", "material-icons": "^1.13.12", diff --git a/src/layout/content/showcase/showcase-page.js b/src/layout/content/showcase/showcase-page.js index 1776b0b..3d84c3c 100644 --- a/src/layout/content/showcase/showcase-page.js +++ b/src/layout/content/showcase/showcase-page.js @@ -5,19 +5,30 @@ import './showcase-component.js'; import '../../../components/code-block/code-block'; import showcasePageCss from './showcase-page.scss?inline'; import rawStartTimeExample from '../../../../static/showcases/start-time.html?raw'; -import raeMultiPlayerExample from '../../../../static/showcases/multi-player.html?raw'; +import rawMultiPlayerExample from '../../../../static/showcases/multi-player.html?raw'; +import rawDetectBlockedSegmentsExample from '../../../../static/showcases/blocked-segment.html?raw'; +import rawDisplayCurrentChapterExample from '../../../../static/showcases/chapters.html?raw'; +import rawSkipCreditsExample from '../../../../static/showcases/skip-credits.html?raw'; import { getTextFromHTML } from './example-parser.js'; const startTimeExampleTxt = getTextFromHTML(rawStartTimeExample); -const multiPlayerExampleTxt = getTextFromHTML(raeMultiPlayerExample); +const multiPlayerExampleTxt = getTextFromHTML(rawMultiPlayerExample); +const detectBlockedSegmentsExampleTxt = + getTextFromHTML(rawDetectBlockedSegmentsExample); +const displayCurrentChapterExampleTxt = + getTextFromHTML(rawDisplayCurrentChapterExample); +const skipCreditsExampleTxt = getTextFromHTML(rawSkipCreditsExample); export class ShowCasePage extends LitElement { static styles = [theme, animations, unsafeCSS(showcasePageCss)]; render() { return html` - ${this.#renderStartTime()} - ${this.#renderMultiplePlayers()} + ${this.#renderStartTime()} + ${this.#renderMultiplePlayers()} + ${this.#renderDetectBlockedSegments()} + ${this.#renderDisplayCurrentChapter()} + ${this.#renderSkipCredits()} `; } @@ -45,21 +56,82 @@ export class ShowCasePage extends LitElement { #renderMultiplePlayers() { return html` -
- -

Multiple Players

-

- This example demonstrates how to incorporate multiple video players - on a webpage.In this showcase, two players are initialized, each - with its own configuration, a button allows to toggle the mute state - for both players. -

- ${multiPlayerExampleTxt} -
- - Open this showcase - -
+
+ +

Multiple Players

+

+ This example demonstrates how to incorporate multiple video players + on a webpage.In this showcase, two players are initialized, each + with its own configuration, a button allows to toggle the mute state + for both players. +

+ ${multiPlayerExampleTxt} +
+ + Open this showcase + +
+ `; + } + + #renderDetectBlockedSegments() { + return html` +
+ +

Detect Blocked Segments

+

+ This tutorial covers how to use pillarbox to create a plugin that + detects and notifies when a blocked segment is skipped. +

+ ${detectBlockedSegmentsExampleTxt} +
+ + Open this showcase + +
+ `; + } + + #renderDisplayCurrentChapter() { + return html` +
+ +

Display Current Chapter

+

+ This showcase explains how to use pillarbox to create a plugin that + displays the currently playing chapter in a box above the progress + bar. +

+ ${displayCurrentChapterExampleTxt} +
+ + Open this showcase + +
+ `; + } + + #renderSkipCredits() { + return html` +
+ +

Skip Credits

+

+ This example shows how to use pillarbox to create a plugin that adds + a "Skip" button during detected credit intervals. +

+ ${skipCreditsExampleTxt} +
+ + Open this showcase + +
`; } } diff --git a/static/showcases/blocked-segment.html b/static/showcases/blocked-segment.html new file mode 100644 index 0000000..f0ad10b --- /dev/null +++ b/static/showcases/blocked-segment.html @@ -0,0 +1,122 @@ + + + + + + + Pillarbox Demo - Detect blocked segment + + + + + + + +
+

Detect blocked segment

+
+ +
+ + +
+ + + + + + + diff --git a/static/showcases/blocked-segment.scss b/static/showcases/blocked-segment.scss new file mode 100644 index 0000000..11f9738 --- /dev/null +++ b/static/showcases/blocked-segment.scss @@ -0,0 +1,16 @@ +.pbw-blocked-segment-notification { + position: absolute; + right: var(--size-5); + bottom: var(--size-9); + display: flex; + align-items: center; + height: var(--size-6); + color: white; + background-color: rgb(0 0 0 / 70%); + border-radius: var(--radius-3); + box-shadow: var(--shadow-3); + backdrop-filter: blur(5px); + padding-inline: var(--size-2); +} + + diff --git a/static/showcases/chapters-showcase.scss b/static/showcases/chapters-showcase.scss new file mode 100644 index 0000000..d9b54fc --- /dev/null +++ b/static/showcases/chapters-showcase.scss @@ -0,0 +1,43 @@ +.pbw-current-chapter { + position: absolute; + top: calc(var(--size-8) * -1); + left: var(--size-4); + display: flex; + width: var(--size-15); + height: var(--size-9); + color: white; + background-color: rgb(0 0 0 / 50%); + border-radius: var(--radius-2); + box-shadow: var(--shadow-3); + backdrop-filter: sepia(50%); +} + +.vjs-layout-medium { + .pbw-current-chapter { + width: var(--size-14); + } +} + +.vjs-layout-tiny, +.vjs-layout-x-small, +.vjs-layout-small { + .pbw-current-chapter { + display: none; + } +} + +.pbw-chapter-title { + display: -webkit-box; + padding: var(--size-1) var(--size-2); + overflow: hidden; + font-weight: var(--font-weight-3); + text-overflow: ellipsis; + -webkit-line-clamp: 4; + -webkit-box-orient: vertical; +} + +.pbw-chapter-thumbnail { + border-top-left-radius: var(--radius-2); + border-bottom-left-radius: var(--radius-2); + box-shadow: var(--inner-shadow-3); +} diff --git a/static/showcases/chapters.html b/static/showcases/chapters.html new file mode 100644 index 0000000..15dcce5 --- /dev/null +++ b/static/showcases/chapters.html @@ -0,0 +1,120 @@ + + + + + + + Pillarbox Demo - Display Current Chapter + + + + + + + +
+

Display Current Chapter

+
+ +
+ + +
+ + + + + + + diff --git a/static/showcases/skip-credits.html b/static/showcases/skip-credits.html new file mode 100644 index 0000000..3a81cd4 --- /dev/null +++ b/static/showcases/skip-credits.html @@ -0,0 +1,107 @@ + + + + + + + Pillarbox Demo - Skip Credits + + + + + + + +
+

Skip Credits

+
+ +
+ + +
+ + + + + + + diff --git a/static/showcases/skip-showcase.scss b/static/showcases/skip-showcase.scss new file mode 100644 index 0000000..df526b8 --- /dev/null +++ b/static/showcases/skip-showcase.scss @@ -0,0 +1,18 @@ +.vjs-control.vjs-button.pbw-skip-btn { + position: absolute; + right: var(--size-5); + bottom: var(--size-9); + width: var(--size-10); + height: var(--size-6); + color: white; + background-color: rgb(0 0 0 / 70%); + border-radius: var(--radius-3); + box-shadow: var(--shadow-3); + cursor: pointer; + backdrop-filter: blur(5px); + + .vjs-icon-placeholder::before { + font-size: var(--font-size-1); + content: 'Skip >>'; + } +} diff --git a/static/showcases/static-showcase.scss b/static/showcases/static-showcase.scss index 985568c..7f2783c 100644 --- a/static/showcases/static-showcase.scss +++ b/static/showcases/static-showcase.scss @@ -1,7 +1,7 @@ @import '../../scss/index'; body { - max-width: var(--size-sm); + max-width: var(--size-md); } .showcase-content {