Skip to content

Commit 9ce249f

Browse files
committed
Merge branch 'master' of https://github.com/bbc/bigscreen-player into plugin-playback-rate
2 parents 0658eb8 + 18883d5 commit 9ce249f

File tree

85 files changed

+8122
-6930
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+8122
-6930
lines changed

docs/arch/001-native-strategy.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22

33
Originally Added: February 20th, 2019
44

5-
# Context
5+
## Context
66

7-
* As it stands, `bigscreen-player` requires using the `tal` device object - when in `talstrategy` - to obtain a media player for playback
8-
* Since the `tal` device media player exists as a singleton, applications using `talstrategy` can only access one active media element.
9-
* Unlike `msestrategy`, `talstrategy` also requires loading in the extra dependency (`tal` device) - and is therefore limited by the limitations of the `tal` device.
7+
- As it stands, `bigscreen-player` requires using the `tal` device object - when in `talstrategy` - to obtain a media player for playback
8+
- Since the `tal` device media player exists as a singleton, applications using `talstrategy` can only access one active media element.
9+
- Unlike `msestrategy`, `talstrategy` also requires loading in the extra dependency (`tal` device) - and is therefore limited by the limitations of the `tal` device.
1010

11-
# Decision
12-
* A new strategy type - `nativestrategy` - has been created which pulls the media player out of `tal`
13-
* This is a refactor of the `tal` device media player code which allows further manipulation and control i.e. multiple video playback
11+
## Decision
1412

13+
- A new strategy type - `nativestrategy` - has been created which pulls the media player out of `tal`
14+
- This is a refactor of the `tal` device media player code which allows further manipulation and control i.e. multiple video playback
15+
16+
## Status
1517

16-
# Status
1718
Approved
1819

19-
# Consequences
20-
* Multiple active video instances can be controlled
21-
* Preloading of content on different media elements is more achievable
22-
* The successful migration of all media player code from `tal` will create much greater modularity for `bigscreen-player` - therefore removing any limitations introduced by the current coupling with `tal`
20+
## Consequences
21+
22+
- Multiple active video instances can be controlled
23+
- Preloading of content on different media elements is more achievable
24+
- The successful migration of all media player code from `tal` will create much greater modularity for `bigscreen-player` - therefore removing any limitations introduced by the current coupling with `tal`

docs/arch/002-sinon.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ Accepted
2121

2222
## Consequences
2323

24-
* Using sinon makes it simpler to provide custom responses to network requests.
25-
* Another third party library is now pulled into bigscreen-player as a dev dependency.
24+
- Using sinon makes it simpler to provide custom responses to network requests.
25+
- Another third party library is now pulled into bigscreen-player as a dev dependency.
2626

2727
## Further Reading
2828

29-
See https://sinonjs.org/ for more information
29+
See <https://sinonjs.org/> for more information

docs/arch/003-subtitles-polling-frequency.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Originally Added: April 7th, 2020
44

55
## Context
66

7-
Subtitles in Bigscreen Player are updated by checking for the next available subtitle using a set timeout of 750ms.
7+
Subtitles in Bigscreen Player are updated by checking for the next available subtitle using a set timeout of 750ms.
88
This number of 750ms was originally used with no record of why it was picked, and is also potentially too infrequent to keep the subtitles perfectly in sync with the audio and visual cues.
99
There was a piece of work done to increase the polling rate to 250ms, however we found that this caused some slower devices to buffer due to the increased load on the devices memory.
1010

@@ -18,5 +18,5 @@ Accepted
1818

1919
## Consequences
2020

21-
* Synchronisation issues are negligible.
22-
* It does not cause device performance to suffer.
21+
- Synchronisation issues are negligible.
22+
- It does not cause device performance to suffer.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# 004 Removing `windowType`; changing time representation
2+
3+
Originally added: 2025-02-03
4+
5+
## Status
6+
7+
| Discussing | Approved | Superceded |
8+
| ---------- | -------- | ---------- |
9+
| | x | |
10+
11+
## Context
12+
13+
BigscreenPlayer supports DASH and HLS streaming. Each transfer format (aka streaming protocol) represents time in a stream in a different way. BigscreenPlayer normalised these times in versions prior to v9.0.0. This normalisation made multiple assumptions:
14+
15+
- The timestamp in the media samples are encoded as UTC times (in seconds) for "sliding window" content i.e. streams with time shift.
16+
- Streams with time shift never use a presentation time offset.
17+
18+
What is more, metadata (i.e. the `windowType`) determined BigscreenPlayer's manifest parsing strategy from v7.1.0 and codified these assumptions.
19+
20+
- How might we overhaul our time representation to support streams that don't comply with these assumptions?
21+
22+
### Considered Options
23+
24+
1. Expose time reported by the `MediaElement` directly. Provide functions to convert the time from the `MediaElement` into availability and media sample time.
25+
2. Do not apply time correction based on `timeShiftBufferDepth` if `windowType === WindowTypes.GROWING`
26+
3. Do not apply time correction based on `timeShiftBufferDepth` if SegmentTemplates in the MPD have `presentationTimeOffset`
27+
28+
## Decision
29+
30+
Chosen option: 1
31+
32+
This approach provides a lot of flexibility to consumers of BigscreenPlayer. It also simplifies time-related calculations such as failover, start time, and subtitle synchronisation.
33+
34+
## Consequences
35+
36+
A major version (v9.0.0) to remove window type and overhaul BigscreenPlayer's internals.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# 005 Remove fake seeking from restartable strategy
2+
3+
Originally added: 2025-02-04
4+
5+
## Status
6+
7+
| Discussing | Approved | Superceded |
8+
| ---------- | -------- | ---------- |
9+
| | x | |
10+
11+
## Context
12+
13+
Native media players with the capability to start playback in a livestream from any (available) point in the stream are called "restartable" in BigscreenPlayer's jargon. Unlike "seekable" devices, "restartable" devices don't support in-stream navigation. In other words, seeking is not supported.
14+
15+
BigscreenPlayer exploited this restart capability to implement "fake seeking" prior to v9.0.0. The restartable player effectively polyfilled the native media player's implementation of `MediaElement#currentTime` and `MediaElement#seekable`. This polyfill relied on the `windowType` metadata to make assumptions about the shape of the stream's seekable range. v9.0.0 deprecates `windowType`.
16+
17+
- Should we continue to support fake seeking for native playback?
18+
- How might we continue to support fake seeking?
19+
20+
### Considered Options
21+
22+
1. Remove fake seeking from restartable strategy
23+
2. Poll the HLS manifest for time shift
24+
3. Provide a "magic" time shift buffer depth for HLS streams
25+
26+
## Decision
27+
28+
Chosen option: 1
29+
30+
The effort to contine support for fake seeking on restartable devices is not justified by the small number of people that benefit from the continued support.
31+
32+
## Consequences
33+
34+
Viewers that use devices on the restartable strategy will no longer be able to pause or seek in-stream.

docs/arch/006-detect-autoresume.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# 006 Detect timeshift to enable auto-resume
2+
3+
Originally added: 2025-02-04
4+
5+
## Status
6+
7+
| Discussing | Approved | Superceded |
8+
| ---------- | -------- | ---------- |
9+
| | x | |
10+
11+
## Context
12+
13+
BigscreenPlayer's auto-resume feature prevents undefined behaviour when native players resume playback outside the seekable range. Auto-resume consists of two mechanisms:
14+
15+
1. Playback is resumed before current time can drift outside of the seekable range
16+
2. Pausing isn't possible when current time is close to the start of the seekable range
17+
18+
Auto-resume is only relevant for streams with time shift. The presence of time shift was signalled through the `windowType === WindowTypes.SLIDING` parameter prior to v9.0.0. v9.0.0 deprecates `windowType`.
19+
20+
DASH manifests explicitly encode the time shift of the stream through the `timeShiftBufferDepth`. On the other hand, time shift in HLS manifests is only detectable by refreshing the manifest.
21+
22+
- How might we detect timeshift and enable the auto-resume feature for DASH and HLS streams?
23+
24+
### Considered Options
25+
26+
1. Poll the HLS manifest to check if the first segment changes
27+
2. Poll the seekable range for changes to the start of the seekable range
28+
3. Provide a "magic" time shift buffer depth for HLS streams
29+
30+
## Decision
31+
32+
Chosen option: 2
33+
34+
## Consequences
35+
36+
The time it takes the `timeshiftdetector` to detect and signal timeshift depends on it's polling rate. Hence, there is a risk the user navigates outside of the seekable range in the span of time before the `timeshiftdetector` detects a sliding seekable range.

docs/arch/007-estimate-hls-ast.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# 007 Estimate HLS Availability Start Time
2+
3+
Originally added: 2025-02-04
4+
5+
## Status
6+
7+
| Discussing | Approved | Superceded |
8+
| ---------- | -------- | ---------- |
9+
| | x | |
10+
11+
## Context
12+
13+
BigscreenPlayer adds functions to convert between three timelines:
14+
15+
1. Presentation time: Output by the MediaElement
16+
2. Media sample time: Timestamps encoded in the current media
17+
3. Availablity time: UTC times that denote time available. Only relevant for dynamic streams.
18+
19+
BigscreenPlayer relies on metadata in the manifest to calculate each conversion.
20+
21+
For DASH:
22+
23+
- Presentation time <-> Media sample time relies on `presentationTimeOffset`
24+
- Presentation time <-> Availability time relies on `availabilityStartTime`
25+
26+
For HLS:
27+
28+
- Presentation time <-> Media sample time relies on `programDateTime`
29+
- Presentation time <-> Availability time relies on ???
30+
31+
HLS signals availability through the segment list. An HLS media player must refresh the segment list to track availability. Availability start time can be estimated as the difference between the current wallclock time and the duration of the stream so far. This estimate should also correct for any difference between the client and server's UTC wallclock time.
32+
33+
### Considered Options
34+
35+
1. Accept the conversion between availability and presentation time is broken for HLS streams.
36+
2. Estimate availability start time for HLS streams. This requires clients provide the offset between the client and server's UTC wallclock time in order to synchronise the calculation.
37+
38+
## Decision
39+
40+
Chosen option: 1
41+
42+
## Consequences
43+
44+
The conversion between presentation time and availability start time is erroneous for HLS.

docs/arch/__template.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# 000 Title
2+
3+
Originally added:
4+
5+
## Status
6+
7+
| Discussing | Approved | Superceded |
8+
| ---------- | -------- | ---------- |
9+
| | x | |
10+
11+
## Context
12+
13+
### [Considered Options]
14+
15+
Optional
16+
17+
## Decision
18+
19+
## Consequences

docs/tutorials/00-getting-started.md

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ Configuration for bigscreen-player can be set using an object on the window:
2222
window.bigscreenPlayer
2323
```
2424

25-
You must provide a *playback strategy* to use BigscreenPlayer:
25+
You must provide a _playback strategy_ to use BigscreenPlayer:
2626

2727
```javascript
28-
window.bigscreenPlayer.playbackStrategy = 'msestrategy' // OR 'nativestrategy' OR 'basicstrategy'
28+
window.bigscreenPlayer.playbackStrategy = "msestrategy" // OR 'nativestrategy' OR 'basicstrategy'
2929
```
3030

31-
The MSEStrategy uses DASH. It is most likely what you want. More detail in the [documentation on playback strategies](<https://bbc.github.io/bigscreen-player/api/tutorial-01-playback-strategies.html>). You should also have a peek at the [documentation on settings and overrides](https://bbc.github.io/bigscreen-player/api/tutorial-02-settings-and-overrides.html)
31+
The `msestrategy` uses Dash.js under the hood. It is likely to be what you want. You should read [the documentation on playback strategies](https://bbc.github.io/bigscreen-player/api/tutorial-01-playback-strategies.html) if you want to use a native media player from your browser. You should also have a peek at the [documentation on settings and overrides](https://bbc.github.io/bigscreen-player/api/tutorial-02-settings-and-overrides.html)
3232

3333
### Minimal Data
3434

@@ -37,9 +37,9 @@ You must provide a manifest and its MIME type.
3737
```javascript
3838
const minimalData = {
3939
media: {
40-
type: 'application/dash+xml',
41-
urls: [{ url: 'https://example.com/video.mpd' }]
42-
}
40+
type: "application/dash+xml",
41+
urls: [{ url: "https://example.com/video.mpd" }],
42+
},
4343
}
4444
```
4545

@@ -67,9 +67,7 @@ playbackElement.id = 'BigscreenPlayback'
6767

6868
body.appendChild(playbackElement)
6969

70-
const enableSubtitles = false
71-
72-
bigscreenPlayer.init(playbackElement, optionalData, WindowTypes.STATIC, enableSubtitles)
70+
bigscreenPlayer.init(playbackElement, minimalData)
7371
```
7472

7573
## All Options
@@ -79,45 +77,50 @@ The full set of options for BigscreenPlayer is:
7977
```javascript
8078
const optionalData = {
8179
initialPlaybackTime: 0, // Time (in seconds) to begin playback from
80+
enableSubtitles: false,
8281
media: {
83-
type: 'application/dash+xml',
82+
type: "application/dash+xml",
8483
kind: MediaKinds.VIDEO, // Can be VIDEO, or AUDIO
8584
urls: [
8685
// Multiple urls offer the ability to fail-over to another CDN if required
8786
{
88-
url: 'https://example.com/video.mpd',
89-
cdn: 'origin' // For Debug Tool reference
90-
}, {
91-
url: 'https://failover.example.com/video.mpd',
92-
cdn: 'failover'
93-
}
87+
url: "https://example.com/video.mpd",
88+
cdn: "origin", // For Debug Tool reference
89+
},
90+
{
91+
url: "https://failover.example.com/video.mpd",
92+
cdn: "failover",
93+
},
9494
],
95-
captions: [{
96-
url: 'https://example.com/captions/$segment$', // $segment$ required for replacement for live subtitle segments
97-
segmentLength: 3.84, // Required to calculate live subtitle segment to fetch & live subtitle URL.
98-
cdn: 'origin' // Displayed by Debug Tool
99-
}, {
100-
url: 'https://failover.example.com/captions/$segment$',
101-
segmentLength: 3.84,
102-
cdn: 'failover'
103-
}
95+
captions: [
96+
{
97+
url: "https://example.com/captions/$segment$", // $segment$ required for replacement for live subtitle segments
98+
segmentLength: 3.84, // Required to calculate live subtitle segment to fetch & live subtitle URL.
99+
cdn: "origin", // Displayed by Debug Tool
100+
},
101+
{
102+
url: "https://failover.example.com/captions/$segment$",
103+
segmentLength: 3.84,
104+
cdn: "failover",
105+
},
104106
],
105-
captionsUrl: 'https://example.com/imsc-doc.xml', // NB This parameter is being deprecated in favour of the captions array shown above.
107+
captionsUrl: "https://example.com/imsc-doc.xml", // NB This parameter is being deprecated in favour of the captions array shown above.
106108
subtitlesRequestTimeout: 5000, // Optional override for the XHR timeout on sidecar loaded subtitles
107109
subtitleCustomisation: {
108110
size: 0.75,
109-
lineHeight: 1.10,
110-
fontFamily: 'Arial',
111-
backgroundColour: 'black' // (css colour, hex)
111+
lineHeight: 1.1,
112+
fontFamily: "Arial",
113+
backgroundColour: "black", // (css colour, hex)
112114
},
113-
playerSettings: { // See settings documentation for more details
115+
playerSettings: {
116+
// See settings documentation for more details
114117
failoverResetTime: 60000,
115118
streaming: {
116119
buffer: {
117-
bufferToKeep: 8
118-
}
119-
}
120-
}
121-
}
120+
bufferToKeep: 8,
121+
},
122+
},
123+
},
124+
},
122125
}
123126
```

0 commit comments

Comments
 (0)