SRGSSR / pillarbox-web

Pillarbox is a versatile media playback ecosystem engineered for the web.
https://srgssr.github.io/pillarbox-web-demo/
MIT License
11 stars 1 forks source link

feat: handle chapters, block segments, time intervals, remote text tracks #207

Closed amtins closed 6 months ago

amtins commented 6 months ago

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

// 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
});

Chapters

Chapters are used to define the start and end times of the various subjects comprising a media item. Resolves #204

// 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.text); // note that active can be undefined
});

Intervals

Intervals allow you to define the start and end times for the credits of a media item. Resolves #212

// 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
});

Changes made

github-actions[bot] commented 6 months ago

Coverage report

St.:grey_question:
Category Percentage Covered / Total
🟒 Statements
97.89% (-0.5% πŸ”»)
558/570
🟒 Branches
94.58% (+1.13% πŸ”Ό)
279/295
🟒 Functions
99.35% (-0.65% πŸ”»)
153/154
🟒 Lines
98.52% (-0.64% πŸ”»)
532/540
Show files with reduced coverage πŸ”»
|
St.:grey_question:
| File | Statements | Branches | Functions | Lines | | :----------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------- | :------------------------------------------------------------- | :------------------------------------------------------------- | :----------------------------------------------------------- | :----------------------------------------------------------- | | 🟒 |
`...` / srgssr.js
|
95.38% (-1.39% πŸ”»)
|
95.18% (+6.61% πŸ”Ό)
|
97.14% (-2.86% πŸ”»)
|
96.43% (-3.57% πŸ”»)
|

Test suite run success

180 tests passing in 9 suites.

Report generated by πŸ§ͺjest coverage report action from 6103f47d47e3245e67fb77fcb5972967deeeaad8

github-actions[bot] commented 6 months ago

PR Preview Action v1.4.7 :---: Preview removed because the pull request was closed. 2024-02-23 17:27 UTC

github-actions[bot] commented 6 months ago

:tada: This PR is included in version 1.1.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: