-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: handle chapters, block segments, time intervals, remote text tracks #207
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Coverage report
Show files with reduced coverage 🔻
Test suite run success180 tests passing in 9 suites. Report generated by 🧪jest coverage report action from 6103f47 |
ea4d7d8
to
06f5926
Compare
|
jboix
added a commit
to SRGSSR/pillarbox-web-demo
that referenced
this pull request
Feb 23, 2024
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.
Today, it's not possible to retrieve the identifier of the media currently being played. In some cases, however, this information may be of interest to the developer. This modification fills the gap by exposing the URN through the `mediaData` object accessible from the player current source. ```javascript // Access the media URN player.currentSource().mediaData.urn ``` - add `urn` property to `mediaComposition.getMainResources` - update `getMainResources` test case to ensure that the urn property is exposed
Resolves #203 by adding support for remote subtitles. Some SRG SSR content, such as mp4, may come with subtitles delivered as separate files, so these need to be explicitly added to the player. This also allows the developer to access remote subtitles via the `mediaData` object accessible from the `currentSource` player. ```javascript // Access the media subtitles player.currentSource().mediaData.subtitles ``` - add `subtitles` property to `mediaComposition.getMainResources` - add a function to add remote subtitles to the player from the srgssr middleware - add remote `subtitles` when resolving the resource in the setSource function - add test cases - replace the default media in the test page with an example containing multiple remote subtitles
Resolves #204 by allowing developers to access chapters directly from the player's text tracks. Chapters can be accessed in two ways. The first is raw data via the `mediaData` object from player `currentSource`. The second is via the player's `textTracks`. This last method allows to listen to the cuechange event and react as accordingly. ```javascript // Accessing raw data player.currentSource().mediaData.chapters; // Listen for cuechange events and get the active cue player.textTracks().getTrackById('srgssr-chapters').on('cuechange', ()=>{ const [active] = Array.from(player.textTracks().getTrackById('srgssr-chapters').activeCues); JSON.parse(active); // note that active can be undefined }); ``` - add the `chapters` property to `mediaComposition` - add a function to add `chapters` to the `player` - add the `chapters` when resolving the resource in the `setSource` function - add test cases - add test media containing multiple chapters
jboix
reviewed
Feb 23, 2024
jboix
added a commit
to SRGSSR/pillarbox-web-demo
that referenced
this pull request
Feb 23, 2024
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.
Resolves #212 by giving developers access to intervals directly from the player's text tracks. Intervals, as defined by SRG SSR, can be used, for example, to define the position of the opening and closing credits of a media. Intervals can be accessed in several ways. The first is raw data via the mediaData object from player currentSource. The second is via the player's textTracks. This latter method allows you to listen to the cuechange event and react as required. ```javascript // Accessing raw data player.currentSource().mediaData.intervals; // Listen for cuechange events and get the active cue player.textTracks().getTrackById('srgssr-intervals').on('cuechange', ()=>{ const [active] = Array.from(player.textTracks().getTrackById('srgssr-intervals').activeCues); JSON.parse(active.text); // note that active can be undefined }); ``` - adds the intervals property to the mediaComposition - adds a function for adding intervals to the player - adds intervals when resolving the resource in the setSource function - add test cases - add a test media containing an interval
Resolves #211 by giving developers access to blocked segments directly from the player's text tracks and, preventing them from being played. Blocked segments, as defined at SRG SSR, are portions of media that must not be played for various reasons such as legal, geo-blocked etc. Blocked segments can be accessed in two ways. The first is raw data via the mediaData object from player currentSource. The second is access via the player's textTracks. This latter method allows you to listen to the cuechange event and react accordingly. ```javascript // Accessing raw data player.currentSource().mediaData.blockedSegments; // Listen for cuechange events and get the active cue player.textTracks().getTrackById('srgssr-blocked-segments').on('cuechange', ()=>{ const [active] = Array .from(player.textTracks().getTrackById('srgssr-blocked-segments').activeCues); JSON.parse(active.text); // note that active can be undefined }); ``` - adds the blockedSegments property to mediaComposition - adds a function to add blocked segments to the player - adds a function to retrieve blocked segments from the player - adds a function to retrieve the end time of a blocked segment - adds functions for passing blocked segments - adds blocked segments when resolving the resource in the setSource function - add test cases
…racks This modification removes duplicate code from functions used to add text tracks for blocked segments, chapters and intervals. - update `addBlockedSegments` - updat `addChapters` - updat `addIntervals` - add `createTextTrack`, creates a `metadata` text track with a specific ID - add `addTextTrackCue`, adds CUEs to a text track - add `addTextTracks`, consolidates the addition of different text tracks in the player to a single location
jboix
approved these changes
Feb 23, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
🎉 This PR is included in version 1.1.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
jboix
added a commit
to SRGSSR/pillarbox-web-demo
that referenced
this pull request
Feb 23, 2024
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.
jboix
added a commit
to SRGSSR/pillarbox-web-demo
that referenced
this pull request
Feb 23, 2024
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.
jboix
added a commit
to SRGSSR/pillarbox-web-demo
that referenced
this pull request
Feb 23, 2024
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.
jboix
added a commit
to SRGSSR/pillarbox-web-demo
that referenced
this pull request
Feb 23, 2024
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.
jboix
added a commit
to SRGSSR/pillarbox-web-demo
that referenced
this pull request
Feb 26, 2024
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.
jboix
added a commit
to SRGSSR/pillarbox-web-demo
that referenced
this pull request
Feb 26, 2024
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.
github-merge-queue bot
pushed a commit
to SRGSSR/pillarbox-web-demo
that referenced
this pull request
Feb 26, 2024
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds support for blocked segments, chapters, intervals and remote text tracks.
To allow developers to create their own experience, metadata text tracks are used. This type of text track has the advantage of not being displayed on screen, however, it is possible to listen to cue change events and react to them as required.
Usage and definition
Blocked segments
Blocked segments are portions of content that must not be played for various reasons, such as legal, geo-blocking, etc. Resolves #211
Chapters
Chapters are used to define the start and end times of the various subjects comprising a media item. Resolves #204
Intervals
Intervals allow you to define the start and end times for the credits of a media item. Resolves #212
Changes made