Skip to content

Commit c03d8f2

Browse files
authored
docs: expand on seeking by timeline (#414)
1 parent d11b9cf commit c03d8f2

15 files changed

+118
-69
lines changed

docs/tutorials/01-playback-strategies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This requires additional config to select which media player implementation to u
3434
window.bigscreenPlayer.mediaPlayer: 'html5'
3535
```
3636

37-
You must also indicate the device's live playback capability. There's more info in [the documentation on live-streaming](https://bbc.github.io/bigscreen-player/api/tutorial-live-streaming.html)
37+
You must also indicate the device's live playback capability. There's more info in [the documentation on live-streaming](https://bbc.github.io/bigscreen-player/api/tutorial-10-live-streaming.html)
3838

3939
```javascript
4040
window.bigscreenPlayer.liveSupport = "seekable"
File renamed without changes.
File renamed without changes.
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Bigscreen Player uses a variety of events to signal its current state.
33
## Reacting to state changes
44

55
State changes which are emitted from the player can be acted upon to by registering a callback. The callback will receive all of the following state changes as the `state` property of the event:
6+
67
- `MediaState.STOPPED`
78
- `MediaState.PAUSED`
89
- `MediaState.PLAYING`
@@ -13,17 +14,17 @@ State changes which are emitted from the player can be acted upon to by register
1314
State changes may be registered for before initialisation and will automatically be cleared upon `tearDown()` of the player.
1415

1516
```javascript
16-
var bigscreenPlayer = BigscreenPlayer();
17+
var bigscreenPlayer = BigscreenPlayer()
1718

1819
// The token is only required in the case where the function is anonymous, a reference to the function can be stored and used to unregister otherwise.
1920
var stateChangeToken = bigscreenPlayer.registerForStateChanges(function (event) {
20-
if(event.state == MediaState.PLAYING) {
21-
console.log('Playing');
21+
if (event.state == MediaState.PLAYING) {
22+
console.log("Playing")
2223
// handle playing event
2324
}
24-
});
25+
})
2526

26-
bigscreenPlayer.unRegisterForStateChanges(stateChangeToken);
27+
bigscreenPlayer.unRegisterForStateChanges(stateChangeToken)
2728
```
2829

2930
## Reacting to time updates
@@ -33,14 +34,14 @@ Time updates are emitted multiple times a second. Your application can register
3334
Time updates may be registered for before initialisation and will automatically be cleared upon `tearDown()` of the player.
3435

3536
```javascript
36-
var bigscreenPlayer = BigscreenPlayer();
37+
var bigscreenPlayer = BigscreenPlayer()
3738

3839
// The token is only required in the case where the function is anonymous, a reference to the function can be stored and used to unregister otherwise.
3940
var timeUpdateToken = bigscreenPlayer.registerForTimeUpdates(function (event) {
40-
console.log('Current Time: ' + event.currentTime);
41-
});
41+
console.log("Current Time: " + event.currentTime)
42+
})
4243

43-
bigscreenPlayer.unRegisterForTimeUpdates(timeUpdateToken);
44+
bigscreenPlayer.unRegisterForTimeUpdates(timeUpdateToken)
4445
```
4546

4647
## Reacting to subtitles being turned on/off
@@ -50,12 +51,12 @@ This is emitted on every `setSubtitlesEnabled` call. The emitted object contains
5051
This may be registered for before initialisation and will automatically be cleared upon `tearDown()` of the player.
5152

5253
```javascript
53-
var bigscreenPlayer = BigscreenPlayer();
54+
var bigscreenPlayer = BigscreenPlayer()
5455

5556
// The token is only required in the case where the function is anonymous, a reference to the function can be stored and used to unregister otherwise.
5657
var subtitleChangeToken = bigscreenPlayer.registerForSubtitleChanges(function (event) {
57-
console.log('Subttiles enabled: ' + event.enabled);
58-
});
58+
console.log("Subttiles enabled: " + event.enabled)
59+
})
5960

60-
bigscreenPlayer.unregisterForSubtitleChanges(subtitleChangeToken);
61-
```
61+
bigscreenPlayer.unregisterForSubtitleChanges(subtitleChangeToken)
62+
```
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ During playback, `bigscreen-player` may change state (e.g enter buffering, pause
22

33
The following diagram describes the flow of these events.
44

5-
![State Changes](../static/bsp_state_changes_august_2019.png)
5+
![State Changes](../static/bsp_state_changes_august_2019.png)
File renamed without changes.
File renamed without changes.
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
A seek is initiated by `BigscreenPlayer#setCurrentTime()`. It can take a number or a number and a timeline. Each timeline is defined in the `Timeline` enum.
1+
A seek is initiated by `BigscreenPlayer#setCurrentTime()`.
2+
3+
```js
4+
bigscreenPlayer.setCurrentTime(30) // seeks in seconds
5+
```
6+
7+
You can also specify [a timeline (read more in section: Timelines)](#timelines) to anchor your seek:
8+
9+
```js
10+
bigscreenPlayer.setCurrentTime(Date.now() / 1000 - 60, Timeline.AVAILABILITY_TIME)
11+
```
212

313
BigscreenPlayer will signal a seek is in progress through the `isSeeking` property on the `WAITING` state change.
414

File renamed without changes.

0 commit comments

Comments
 (0)