shaka-player 3.2.2 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
- package/.github/ISSUE_TEMPLATE/feature_request.md +1 -1
- package/.github/ISSUE_TEMPLATE/question.md +1 -1
- package/AUTHORS +6 -5
- package/CHANGELOG.md +247 -0
- package/CONTRIBUTORS +4 -2
- package/build/types/core +3 -0
- package/build/types/offline +1 -0
- package/build/types/polyfill +1 -0
- package/build/types/ui +2 -0
- package/demo/common/assets.js +18 -0
- package/demo/common/message_ids.js +13 -1
- package/demo/config.js +31 -1
- package/demo/index.html +1 -1
- package/demo/locales/en.json +12 -0
- package/demo/locales/source.json +48 -0
- package/dist/controls.css +26 -2
- package/dist/controls.css.map +1 -1
- package/dist/demo.compiled.debug.js +19 -16
- package/dist/demo.compiled.debug.map +3 -3
- package/dist/demo.compiled.js +19 -16
- package/dist/demo.compiled.map +3 -3
- package/dist/deps.js +18 -11
- package/dist/locales.js +28 -26
- package/dist/receiver.compiled.debug.js +11 -9
- package/dist/receiver.compiled.debug.map +3 -3
- package/dist/receiver.compiled.js +11 -9
- package/dist/receiver.compiled.map +3 -3
- package/dist/shaka-player.compiled.d.ts +205 -15
- package/dist/shaka-player.compiled.debug.d.ts +205 -15
- package/dist/shaka-player.compiled.debug.externs.js +256 -6
- package/dist/shaka-player.compiled.debug.js +406 -354
- package/dist/shaka-player.compiled.debug.map +4 -4
- package/dist/shaka-player.compiled.externs.js +256 -6
- package/dist/shaka-player.compiled.js +826 -800
- package/dist/shaka-player.compiled.map +4 -4
- package/dist/shaka-player.ui.d.ts +221 -16
- package/dist/shaka-player.ui.debug.d.ts +221 -16
- package/dist/shaka-player.ui.debug.externs.js +283 -6
- package/dist/shaka-player.ui.debug.js +547 -476
- package/dist/shaka-player.ui.debug.map +4 -4
- package/dist/shaka-player.ui.externs.js +283 -6
- package/dist/shaka-player.ui.js +1019 -980
- package/dist/shaka-player.ui.map +4 -4
- package/docs/design/bg-fetch-after.gv +29 -0
- package/docs/design/bg-fetch-after.gv.png +0 -0
- package/docs/design/bg-fetch-before.gv +18 -0
- package/docs/design/bg-fetch-before.gv.png +0 -0
- package/docs/design/bg-fetch.md +134 -0
- package/docs/tutorials/blob-url.md +15 -0
- package/docs/tutorials/index.json +1 -0
- package/docs/tutorials/ui-customization.md +66 -0
- package/docs/tutorials/ui.md +5 -5
- package/externs/ima.js +3 -0
- package/externs/shaka/ads.js +5 -0
- package/externs/shaka/manifest.js +12 -1
- package/externs/shaka/manifest_parser.js +10 -1
- package/externs/shaka/net.js +20 -4
- package/externs/shaka/offline.js +31 -2
- package/externs/shaka/player.js +130 -5
- package/externs/shaka/text.js +14 -0
- package/externs/webcrypto.js +18 -0
- package/lib/abr/ewma.js +14 -0
- package/lib/abr/ewma_bandwidth_estimator.js +16 -2
- package/lib/abr/simple_abr_manager.js +6 -0
- package/lib/ads/client_side_ad.js +8 -0
- package/lib/ads/client_side_ad_manager.js +8 -4
- package/lib/ads/server_side_ad.js +7 -0
- package/lib/cast/cast_utils.js +1 -0
- package/lib/dash/dash_parser.js +48 -14
- package/lib/dash/segment_base.js +25 -1
- package/lib/dash/segment_list.js +18 -9
- package/lib/dash/segment_template.js +23 -10
- package/lib/hls/hls_parser.js +86 -23
- package/lib/media/quality_observer.js +291 -0
- package/lib/media/segment_index.js +6 -0
- package/lib/media/segment_reference.js +18 -3
- package/lib/media/streaming_engine.js +42 -4
- package/lib/net/http_fetch_plugin.js +31 -11
- package/lib/net/http_plugin_utils.js +1 -0
- package/lib/net/http_xhr_plugin.js +40 -14
- package/lib/net/networking_engine.js +81 -18
- package/lib/offline/download_info.js +68 -0
- package/lib/offline/download_manager.js +13 -5
- package/lib/offline/indexeddb/base_storage_cell.js +35 -0
- package/lib/offline/indexeddb/storage_mechanism.js +1 -1
- package/lib/offline/indexeddb/v5_storage_cell.js +5 -0
- package/lib/offline/storage.js +393 -284
- package/lib/offline/stored_content_utils.js +2 -0
- package/lib/player.js +206 -7
- package/lib/polyfill/random_uuid.js +52 -0
- package/lib/text/cue.js +12 -0
- package/lib/text/ttml_text_parser.js +25 -2
- package/lib/text/ui_text_displayer.js +2 -2
- package/lib/util/cmcd_manager.js +826 -0
- package/lib/util/error.js +6 -0
- package/lib/util/language_utils.js +12 -0
- package/lib/util/mutex.js +52 -0
- package/lib/util/periods.js +98 -64
- package/lib/util/player_configuration.js +18 -0
- package/package.json +1 -1
- package/shaka-player.uncompiled.js +3 -0
- package/test/dash/dash_parser_content_protection_unit.js +2 -0
- package/test/dash/dash_parser_live_unit.js +101 -1
- package/test/dash/dash_parser_manifest_unit.js +35 -1
- package/test/dash/dash_parser_segment_base_unit.js +2 -0
- package/test/dash/dash_parser_segment_list_unit.js +2 -1
- package/test/dash/dash_parser_segment_template_unit.js +2 -1
- package/test/hls/hls_live_unit.js +2 -0
- package/test/hls/hls_parser_unit.js +2 -0
- package/test/media/quality_observer_unit.js +139 -0
- package/test/media/segment_reference_unit.js +16 -1
- package/test/media/streaming_engine_integration.js +2 -1
- package/test/media/streaming_engine_unit.js +2 -0
- package/test/net/http_plugin_unit.js +20 -15
- package/test/offline/storage_integration.js +108 -4
- package/test/player_integration.js +99 -0
- package/test/test/util/dash_parser_util.js +4 -0
- package/test/test/util/fake_ad.js +7 -0
- package/test/test/util/fake_drm_engine.js +9 -2
- package/test/test/util/manifest_generator.js +3 -2
- package/test/test/util/test_scheme.js +14 -1
- package/test/text/ttml_text_parser_unit.js +47 -0
- package/test/ui/ui_unit.js +250 -0
- package/test/util/cmcd_manager_unit.js +277 -0
- package/ui/airplay_button.js +1 -0
- package/ui/audio_language_selection.js +7 -0
- package/ui/cast_button.js +1 -0
- package/ui/context_menu.js +109 -0
- package/ui/controls.js +41 -7
- package/ui/controls.less +1 -0
- package/ui/enums.js +4 -0
- package/ui/externs/ui.js +28 -1
- package/ui/fast_forward_button.js +14 -5
- package/ui/fullscreen_button.js +1 -0
- package/ui/less/buttons.less +0 -4
- package/ui/less/containers.less +74 -0
- package/ui/less/overflow_menu.less +0 -10
- package/ui/less/tooltip.less +97 -0
- package/ui/locales/en.json +1 -0
- package/ui/locales/source.json +4 -0
- package/ui/loop_button.js +5 -0
- package/ui/mute_button.js +2 -1
- package/ui/overflow_menu.js +5 -25
- package/ui/pip_button.js +5 -0
- package/ui/play_button.js +2 -2
- package/ui/playback_rate_selection.js +8 -9
- package/ui/resolution_selection.js +7 -0
- package/ui/rewind_button.js +15 -6
- package/ui/seek_bar.js +4 -2
- package/ui/settings_menu.js +36 -4
- package/ui/small_play_button.js +1 -0
- package/ui/statistics_button.js +253 -0
- package/ui/text_selection.js +11 -4
- package/ui/ui.js +30 -0
- package/ui/volume_bar.js +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Generate png with: dot -Tpng -O after.gv
|
|
2
|
+
digraph storage_after {
|
|
3
|
+
subgraph cluster_0 {
|
|
4
|
+
label="Shaka Player";
|
|
5
|
+
parse[label="Download and parse manifest (parseManifest)"];
|
|
6
|
+
drm[label="Make DRM engine and load keys (createDrmEngine)"]
|
|
7
|
+
filter[label="Filter manifest (filterManifest_)"];
|
|
8
|
+
segments[label="Download segments (downloadSegments_)"];
|
|
9
|
+
store[label="Store manifest (cell.addManifests)"];
|
|
10
|
+
parse -> drm;
|
|
11
|
+
drm -> filter;
|
|
12
|
+
filter -> store;
|
|
13
|
+
store -> segments[label="BG Fetch Not Available"];
|
|
14
|
+
}
|
|
15
|
+
subgraph cluster_1 {
|
|
16
|
+
label="Service Worker";
|
|
17
|
+
bgSegments[label="Download segments in background (backgroundFetch.fetch)"]
|
|
18
|
+
store -> bgSegments[label="BG Fetch Available"];
|
|
19
|
+
}
|
|
20
|
+
subgraph cluster_2 {
|
|
21
|
+
label="Shaka Player Static Methods";
|
|
22
|
+
storeSeg[label="Store segments one-by-one (assignStreamToManifest)"]
|
|
23
|
+
remove[label="Clean up (cleanStoredManifest)"];
|
|
24
|
+
segments -> remove[label="On Fail"];
|
|
25
|
+
segments -> storeSeg;
|
|
26
|
+
bgSegments -> storeSeg;
|
|
27
|
+
bgSegments -> remove[label="On Fail"];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Generate png with: dot -Tpng -O before.gv
|
|
2
|
+
digraph storage_before {
|
|
3
|
+
subgraph cluster_0 {
|
|
4
|
+
label="Shaka Player";
|
|
5
|
+
parse[label="Download and parse manifest (parseManifest)"];
|
|
6
|
+
drm[label="Make DRM engine and load keys (createDrmEngine)"]
|
|
7
|
+
filter[label="Filter manifest (filterManifest_)"];
|
|
8
|
+
segments[label="Download and store segments (downloadManifest_)"];
|
|
9
|
+
store[label="Store manifest (cell.addManifests)"];
|
|
10
|
+
remove[label="Clean up (cell.removeSegments)"];
|
|
11
|
+
parse -> drm;
|
|
12
|
+
drm -> filter;
|
|
13
|
+
filter -> segments;
|
|
14
|
+
segments -> store;
|
|
15
|
+
segments -> remove[label="On Fail"];
|
|
16
|
+
store -> remove[label="On Fail"];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Shaka Player Background Fetch Support
|
|
2
|
+
|
|
3
|
+
last update: 2021-7-12
|
|
4
|
+
|
|
5
|
+
by: [theodab@google.com](mailto:theodab@google.com)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
The feature of background fetch has been in Shaka Player’s backlog [since 2017].
|
|
11
|
+
At the time it was added to the backlog, the feature was not quite ready for
|
|
12
|
+
use. Since then, it has matured, and now is something we could feasibly use, but
|
|
13
|
+
it has still been a low-priority feature.
|
|
14
|
+
|
|
15
|
+
[since 2017]: https://github.com/google/shaka-player/issues/879
|
|
16
|
+
|
|
17
|
+
## Design Concept
|
|
18
|
+
|
|
19
|
+
This design attempts to reuse existing code whenever possible, in order to
|
|
20
|
+
minimize the amount of new code that has to be tested. The code will be made in
|
|
21
|
+
two main stages:
|
|
22
|
+
1. Refactor the offline download process to change the order that the asset is
|
|
23
|
+
downloaded. The manifest should be downloaded and stored first, and then every
|
|
24
|
+
segment should be downloaded. As a segment is downloaded, it should be stored.
|
|
25
|
+
The code for storing a segment, in particular, should be broken out into an
|
|
26
|
+
exported static (e.g. stateless) function.
|
|
27
|
+
1. Modify the Shaka Player wrapper to add the appropriate background fetch event
|
|
28
|
+
listeners if the environment is detected to be a service worker, so that a
|
|
29
|
+
compiled Shaka Player bundle can be used as a service worker. If background
|
|
30
|
+
fetch is used, the segment downloading step should be passed to this service
|
|
31
|
+
worker. When each segment is downloaded, it should be passed to the static
|
|
32
|
+
storage functions added in stage 1.
|
|
33
|
+
|
|
34
|
+
By restructuring the offline storage code in this way, switching between
|
|
35
|
+
foreground and background fetch will just be a matter of calling a different
|
|
36
|
+
segment-downloading function. In addition, it is possible that, in the future, a
|
|
37
|
+
plugin interface could be made for this. That probably won’t be necessary unless
|
|
38
|
+
another browser makes a competing API for downloading in the background (which
|
|
39
|
+
is admittedly a possibility, as background fetch [is not yet a W3C standard]).
|
|
40
|
+
|
|
41
|
+
[is not yet a W3C standard]: https://wicg.github.io/background-fetch/
|
|
42
|
+
|
|
43
|
+
### Storage System Process: Before
|
|
44
|
+
|
|
45
|
+

|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Storage System Process: After
|
|
49
|
+
|
|
50
|
+

|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## Implementation
|
|
54
|
+
|
|
55
|
+
### Changes to shaka.offline.Storage
|
|
56
|
+
|
|
57
|
+
1. Change createOfflineManifest_ to leave the storage indexes on the segments
|
|
58
|
+
null at first. With this change, downloadManifest_ will now only be downloading
|
|
59
|
+
the encryption keys (which cannot be downloaded via background fetch, as they
|
|
60
|
+
require request bodies).
|
|
61
|
+
1. Create a new step within store_, after the manifest is stored, called
|
|
62
|
+
“downloadSegments_” that makes a Set of SegmentReference objects that need to be
|
|
63
|
+
downloaded.
|
|
64
|
+
1. We use SegmentReference objects in order to contain the URI, startByte,
|
|
65
|
+
and endByte.
|
|
66
|
+
1. This change also means we will no longer need an internal cache for
|
|
67
|
+
downloaded segments, as they will be deduplicated by the use of a Set.
|
|
68
|
+
1. If background fetch is not available, downloadSegments_ will simply download
|
|
69
|
+
the segments from this set as before, and then once they are all downloaded,
|
|
70
|
+
pass them all to assignStreamsToManifest.
|
|
71
|
+
1. If background fetch is available, this set will be turned into an array,
|
|
72
|
+
Request objects should be made for the individual uris (with appropriate headers
|
|
73
|
+
applied), and then that array will be passed to the service worker with a
|
|
74
|
+
background fetch call. The service worker will then, after everything is
|
|
75
|
+
downloaded and stored, call assignStreamsToManifest. An estimate of the total
|
|
76
|
+
download size will need to be computed here, and padded to avoid premature
|
|
77
|
+
cancellation for inaccurate manifests.
|
|
78
|
+
1. Create a new public static method, assignStreamToManifest. This is a static
|
|
79
|
+
method that requires no internal state, so that the service worker can call it.
|
|
80
|
+
It stores the data provided, loads the manifest from storage, applies the
|
|
81
|
+
storage id of the data to the appropriate segments (based on uri), and then
|
|
82
|
+
stores the modified manifest. It should have a mutex over the part that loads
|
|
83
|
+
and changes the manifest, to keep one invocation from overriding the manifest
|
|
84
|
+
changes of another. It should have the following parameters:
|
|
85
|
+
1. manifestStorageId
|
|
86
|
+
1. uri
|
|
87
|
+
1. data
|
|
88
|
+
1. throwIfAbortedFn
|
|
89
|
+
1. Create a second public static method, cleanStoredManifest. This method is
|
|
90
|
+
meant to be called by the service worker in the instance of the fetch operation
|
|
91
|
+
being aborted, and will simply clear the manifest away. It will also clear any
|
|
92
|
+
segments that have been stored already. This also means we will no longer need
|
|
93
|
+
the segmentsFromStore_ array, which we had previously been using to un-store
|
|
94
|
+
after canceled or failed downloads. It should have the following parameters:
|
|
95
|
+
1. manifestStorageId
|
|
96
|
+
1. When filling out shaka.extern.StoredContent entries for the list() method,
|
|
97
|
+
the storage system should be sure to set the offlineUri field to null if the
|
|
98
|
+
manifest is still “isIncomplete”, to mark that the asset has not yet finished
|
|
99
|
+
downloading. This will help developers detect that an asset is mid-download on
|
|
100
|
+
page load, so that they can set up progress indicators if they so wish.
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
### Service Worker Design
|
|
104
|
+
|
|
105
|
+
1. This code should go in, or at least be loaded in, the wrapper code. This will
|
|
106
|
+
let us access Shaka Player methods inside the service worker, without having to
|
|
107
|
+
coordinate how to load a compiled Shaka Player bundle from a service worker;
|
|
108
|
+
the user can simply load a Shaka Player bundle as a service worker.
|
|
109
|
+
1. When the background fetch message is called (see [the documentation]), the
|
|
110
|
+
“id” field should be set to the storage id of the manifest, with an added prefix
|
|
111
|
+
of “Shaka-”. The API does not provide any field for custom data, but this value
|
|
112
|
+
still needs to be provided to the service worker somehow. Luckily, this is the
|
|
113
|
+
only extra data the service worker needs, so it can just be the id of the fetch
|
|
114
|
+
operation.
|
|
115
|
+
1. When handling background fetch-related events, we can simply ignore any
|
|
116
|
+
event that does not start with the prefix. This will help prevent any
|
|
117
|
+
contamination with other service worker code from the developer.
|
|
118
|
+
1. As each segment is downloaded, the assignStreamToManifest method should be
|
|
119
|
+
called to store that data in the manifest.
|
|
120
|
+
1. If the download is canceled, call the cleanStoredManifest method, so that the
|
|
121
|
+
player doesn’t pollute indexedDb with unused segment data.
|
|
122
|
+
1. As a service worker is essentially just a collection of event listeners, one
|
|
123
|
+
can theoretically listen to the same event multiple times. This is relevant
|
|
124
|
+
because [a given scope] can only have a single service worker, so our service
|
|
125
|
+
worker code will have to be something that other people can load into their
|
|
126
|
+
existing service workers, if they have any.
|
|
127
|
+
1. Our system should use the message event to pass a specific identifying
|
|
128
|
+
message to the service worker, and the service worker will be expected to
|
|
129
|
+
respond with a specific response message. This way, we won’t mistake an
|
|
130
|
+
unrelated service worker for our own.
|
|
131
|
+
1. This message can also be used to make sure the versions are the same.
|
|
132
|
+
|
|
133
|
+
[the documentation]: https://developers.google.com/web/updates/2018/12/background-fetch#starting_a_background_fetch
|
|
134
|
+
[a given scope]: https://developers.google.com/web/fundamentals/primers/service-workers#register_a_service_worker
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Blob URL
|
|
2
|
+
|
|
3
|
+
In case you need shaka-player to load a blob url mpd:
|
|
4
|
+
|
|
5
|
+
`player.load(computedMpdBlobURL, startTime, 'application/dash+xml');`
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
In case you need shaka-player to load a blob url m3u8 :
|
|
9
|
+
|
|
10
|
+
`player.load(computedMpdBlobURL, startTime, 'application/x-mpegurl');`
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Note: relative URIs in the manifest are broken because the original manifest URI is lost. This can be worked around with either absolute URIs or the use of BaseURL element in DASH.
|
|
14
|
+
|
|
15
|
+
Note: this tutorial only applies to v3.3 or higher
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
{ "offline": { "title": "Offline Storage and Playback" } },
|
|
19
19
|
{ "fairplay": { "title": "FairPlay support" } },
|
|
20
20
|
{ "application-level-redirects": { "title": "Application-Level Redirects" } },
|
|
21
|
+
{ "blob-url": { "title": "Blob URL" } },
|
|
21
22
|
{ "faq": { "title": "Frequently Asked Questions" } },
|
|
22
23
|
{ "upgrade": {
|
|
23
24
|
"title": "Upgrade Guide",
|
|
@@ -67,6 +67,10 @@ The following elements can be added to the UI bar using this configuration value
|
|
|
67
67
|
supports AirPlay.
|
|
68
68
|
* cast: adds a button that opens a Chromecast dialog. The button is visible only if there is
|
|
69
69
|
at least one Chromecast device on the same network available for casting.
|
|
70
|
+
* quality: adds a button that controls enabling/disabling of abr and video resolution selection.
|
|
71
|
+
* language: adds a button that controls audio language selection.
|
|
72
|
+
* playback_rate: adds a button that controls the playback rate selection.
|
|
73
|
+
* captions: adds a button that controls the current text track selection (including turning it off).
|
|
70
74
|
<!-- TODO: If we add more buttons that can be put in the order this way, list them here. -->
|
|
71
75
|
|
|
72
76
|
Similarly, the 'overflowMenuButtons' configuration option can be used to control
|
|
@@ -84,6 +88,7 @@ The following buttons can be added to the overflow menu:
|
|
|
84
88
|
* playback_rate: adds a button that controls the playback rate selection.
|
|
85
89
|
* airplay: adds a button that opens a AirPlay dialog. The button is visible only if the browser
|
|
86
90
|
supports AirPlay.
|
|
91
|
+
* Statistics: adds a button that displays statistics of the video.
|
|
87
92
|
<!-- TODO: If we add more buttons that can be put in the order this way, list them here. -->
|
|
88
93
|
|
|
89
94
|
Example:
|
|
@@ -98,6 +103,51 @@ ui.configure(config);
|
|
|
98
103
|
An important note: the 'overflow_menu' button needs to be part of the 'controlPanelElements'
|
|
99
104
|
layout for the overflow menu to be available to the user.
|
|
100
105
|
|
|
106
|
+
#### Adding tooltips to control panel buttons
|
|
107
|
+
|
|
108
|
+
Tooltips can be enabled to display the function of every button in the control panel. Where applicable, they will also contain the current selection in parenthesis.
|
|
109
|
+
|
|
110
|
+
Example:
|
|
111
|
+
```js
|
|
112
|
+
const config = {
|
|
113
|
+
'enableTooltips' : true
|
|
114
|
+
}
|
|
115
|
+
ui.configure(config);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
#### Replacing the default context menu
|
|
119
|
+
|
|
120
|
+
A custom context menu can be added through the `customContextMenu` boolean. Additionally, the `contextMenuElements` option can be used to add elements to it.
|
|
121
|
+
The following buttons can be added to the context menu:
|
|
122
|
+
* Statistics: adds a button that displays statistics of the video.
|
|
123
|
+
* loop: adds a button that controls if the currently selected video is played in a loop.
|
|
124
|
+
* picture_in_picture: adds a button that enables/disables picture-in-picture mode on browsers
|
|
125
|
+
that support it. Button is invisible on other browsers.
|
|
126
|
+
|
|
127
|
+
Example:
|
|
128
|
+
```js
|
|
129
|
+
const config = {
|
|
130
|
+
'customContextMenu' : true,
|
|
131
|
+
'contextMenuElements' : ['statistics'],
|
|
132
|
+
}
|
|
133
|
+
ui.configure(config);
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### Configuring Statistics
|
|
137
|
+
The list of statistics that are displayed when toggling the statistics button can be customized by specifying a `statisticsList` on the configuration. With the exception of `switchHistory` and `stateHistory`, all of the statistics from the {@link shaka.extern.Stats `Stats`} extern can be displayed.
|
|
138
|
+
|
|
139
|
+
Example:
|
|
140
|
+
```js
|
|
141
|
+
// Add a context menu with the 'statistics' button that displays a container with
|
|
142
|
+
// the current 'width', 'height', 'playTime', and 'bufferingTime' values.
|
|
143
|
+
const config = {
|
|
144
|
+
'customContextMenu' : true,
|
|
145
|
+
'contextMenuElements' : ['statistics'],
|
|
146
|
+
'statisticsList' : ['width', 'height', 'playTime', 'bufferingTime'],
|
|
147
|
+
}
|
|
148
|
+
ui.configure(config);
|
|
149
|
+
```
|
|
150
|
+
|
|
101
151
|
The presence of the seek bar and the big play button in the center of the video element can be
|
|
102
152
|
customized with `addSeekBar` and `addBigPlayButton` booleans in the config.
|
|
103
153
|
|
|
@@ -130,6 +180,22 @@ const config = {
|
|
|
130
180
|
ui.configure(config);
|
|
131
181
|
```
|
|
132
182
|
|
|
183
|
+
#### Configuring playback, fast forward and rewind rates
|
|
184
|
+
The rate in which the player can play, fast forward and rewind content can be configured using the `playbackRates`, `fastForwardRates` and `rewindRates` options.
|
|
185
|
+
|
|
186
|
+
* `playbackRates`: List of rates available in the `playback_rate` menu.
|
|
187
|
+
* `fastForwardRates`: List of rates available to cycle through every time the `fast_forward` button is clicked.
|
|
188
|
+
* `rewindRates`: List of rates available to cycle through every time the `rewind` button is clicked.
|
|
189
|
+
|
|
190
|
+
```js
|
|
191
|
+
const config = {
|
|
192
|
+
'controlPanelElements': ['playback_rate', 'fast_forward', 'rewind'],
|
|
193
|
+
'playbackRates': [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2],
|
|
194
|
+
'fastForwardRates': [2, 4, 8, 1],
|
|
195
|
+
'rewindRates': [-1, -2, -4, -8],
|
|
196
|
+
}
|
|
197
|
+
ui.configure(config);
|
|
198
|
+
```
|
|
133
199
|
|
|
134
200
|
#### Creating custom elements and adding them to the UI
|
|
135
201
|
It's possible to add custom application-specific buttons to the UI.
|
package/docs/tutorials/ui.md
CHANGED
|
@@ -30,7 +30,7 @@ Set up controls with HTML data attributes:
|
|
|
30
30
|
The data-shaka-player-cast-receiver-id tag allows you to provide a Cast Application ID that
|
|
31
31
|
the cast button will cast to; the value provided here is the sample cast receiver. -->
|
|
32
32
|
<div data-shaka-player-container style="max-width:40em"
|
|
33
|
-
data-shaka-player-cast-receiver-id="
|
|
33
|
+
data-shaka-player-cast-receiver-id="BBED8D28">
|
|
34
34
|
<!-- The data-shaka-player tag will make the UI library use this video element.
|
|
35
35
|
If no video is provided, the UI will automatically make one inside the container div. -->
|
|
36
36
|
<video autoplay data-shaka-player id="video" style="width:100%;height:100%"></video>
|
|
@@ -111,7 +111,7 @@ set up a listener for the 'caststatuschanged' events.
|
|
|
111
111
|
<!-- Add a data-shaka-player-cast-receiver-id tag to provide a Cast Application ID that
|
|
112
112
|
the cast button will cast to; the value provided here is the sample cast receiver. -->
|
|
113
113
|
<div data-shaka-player-container style="max-width:40em"
|
|
114
|
-
data-shaka-player-cast-receiver-id="
|
|
114
|
+
data-shaka-player-cast-receiver-id="BBED8D28">
|
|
115
115
|
</div>
|
|
116
116
|
```
|
|
117
117
|
|
|
@@ -137,7 +137,7 @@ or a `<source>` tag inside it to enable auto loading of the specified content.
|
|
|
137
137
|
|
|
138
138
|
```html
|
|
139
139
|
<div data-shaka-player-container style="max-width:40em"
|
|
140
|
-
data-shaka-player-cast-receiver-id="
|
|
140
|
+
data-shaka-player-cast-receiver-id="BBED8D28">
|
|
141
141
|
<!-- The manifest url in the src attribute will be automatically loaded -->
|
|
142
142
|
<video autoplay data-shaka-player id="video" style="width:100%;height:100%"
|
|
143
143
|
src="https://storage.googleapis.com/shaka-demo-assets/angel-one/dash.mpd"></video>
|
|
@@ -148,7 +148,7 @@ or
|
|
|
148
148
|
|
|
149
149
|
```html
|
|
150
150
|
<div data-shaka-player-container style="max-width:40em"
|
|
151
|
-
data-shaka-player-cast-receiver-id="
|
|
151
|
+
data-shaka-player-cast-receiver-id="BBED8D28">
|
|
152
152
|
<video autoplay data-shaka-player id="video" style="width:100%;height:100%">
|
|
153
153
|
<!-- The manifest url in the src attribute will be auto loaded -->
|
|
154
154
|
<source src="https://storage.googleapis.com/shaka-demo-assets/angel-one/dash.mpd"/>
|
|
@@ -161,7 +161,7 @@ call to the first one fails.
|
|
|
161
161
|
|
|
162
162
|
```html
|
|
163
163
|
<div data-shaka-player-container style="max-width:40em"
|
|
164
|
-
data-shaka-player-cast-receiver-id="
|
|
164
|
+
data-shaka-player-cast-receiver-id="BBED8D28">
|
|
165
165
|
<video autoplay data-shaka-player id="video" style="width:100%;height:100%">
|
|
166
166
|
<!-- Try this first -->
|
|
167
167
|
<source src="https://storage.googleapis.com/shaka-demo-assets/angel-one/dash.mpd"/>
|
package/externs/ima.js
CHANGED
package/externs/shaka/ads.js
CHANGED
|
@@ -238,6 +238,7 @@ shaka.extern.CreateSegmentIndexFunction;
|
|
|
238
238
|
* id: number,
|
|
239
239
|
* originalId: ?string,
|
|
240
240
|
* createSegmentIndex: shaka.extern.CreateSegmentIndexFunction,
|
|
241
|
+
* closeSegmentIndex: (function()|undefined),
|
|
241
242
|
* segmentIndex: shaka.media.SegmentIndex,
|
|
242
243
|
* mimeType: string,
|
|
243
244
|
* codecs: string,
|
|
@@ -263,7 +264,10 @@ shaka.extern.CreateSegmentIndexFunction;
|
|
|
263
264
|
* audioSamplingRate: ?number,
|
|
264
265
|
* spatialAudio: boolean,
|
|
265
266
|
* closedCaptions: Map.<string, string>,
|
|
266
|
-
* tilesLayout: (string|undefined)
|
|
267
|
+
* tilesLayout: (string|undefined),
|
|
268
|
+
* matchedStreams:
|
|
269
|
+
* (!Array.<shaka.extern.Stream>|!Array.<shaka.extern.StreamDB>|
|
|
270
|
+
* undefined)
|
|
267
271
|
* }}
|
|
268
272
|
*
|
|
269
273
|
* @description
|
|
@@ -280,6 +284,9 @@ shaka.extern.CreateSegmentIndexFunction;
|
|
|
280
284
|
* @property {shaka.extern.CreateSegmentIndexFunction} createSegmentIndex
|
|
281
285
|
* <i>Required.</i> <br>
|
|
282
286
|
* Creates the Stream's segmentIndex (asynchronously).
|
|
287
|
+
* @property {(function()|undefined)} closeSegmentIndex
|
|
288
|
+
* <i>Optional.</i> <br>
|
|
289
|
+
* Closes the Stream's segmentIndex.
|
|
283
290
|
* @property {shaka.media.SegmentIndex} segmentIndex
|
|
284
291
|
* <i>Required.</i> <br>
|
|
285
292
|
* May be null until createSegmentIndex() is complete.
|
|
@@ -370,6 +377,10 @@ shaka.extern.CreateSegmentIndexFunction;
|
|
|
370
377
|
* The value is a grid-item-dimension consisting of two positive decimal
|
|
371
378
|
* integers in the format: column-x-row ('4x3'). It describes the arrangement
|
|
372
379
|
* of Images in a Grid. The minimum valid LAYOUT is '1x1'.
|
|
380
|
+
* @property {(!Array.<shaka.extern.Stream>|!Array.<shaka.extern.StreamDB>|
|
|
381
|
+
* undefined)} matchedStreams
|
|
382
|
+
* The streams in all periods which match the stream. Used for Dash.
|
|
383
|
+
*
|
|
373
384
|
* @exportDoc
|
|
374
385
|
*/
|
|
375
386
|
shaka.extern.Stream;
|
|
@@ -100,6 +100,10 @@ shaka.extern.ManifestParser = class {
|
|
|
100
100
|
/**
|
|
101
101
|
* @typedef {{
|
|
102
102
|
* networkingEngine: !shaka.net.NetworkingEngine,
|
|
103
|
+
* modifyManifestRequest: function(!shaka.extern.Request,
|
|
104
|
+
* shaka.util.CmcdManager.ManifestInfo),
|
|
105
|
+
* modifySegmentRequest: function(!shaka.extern.Request,
|
|
106
|
+
* shaka.util.CmcdManager.SegmentInfo),
|
|
103
107
|
* filter: function(shaka.extern.Manifest):!Promise,
|
|
104
108
|
* makeTextStreamsForClosedCaptions: function(shaka.extern.Manifest),
|
|
105
109
|
* onTimelineRegionAdded: function(shaka.extern.TimelineRegionInfo),
|
|
@@ -118,6 +122,12 @@ shaka.extern.ManifestParser = class {
|
|
|
118
122
|
*
|
|
119
123
|
* @property {!shaka.net.NetworkingEngine} networkingEngine
|
|
120
124
|
* The networking engine to use for network requests.
|
|
125
|
+
* @property {function(!shaka.extern.Request,
|
|
126
|
+
* shaka.util.CmcdManager.ManifestInfo)} modifyManifestRequest
|
|
127
|
+
* Modify a manifest request
|
|
128
|
+
* @property {function(!shaka.extern.Request,
|
|
129
|
+
* shaka.util.CmcdManager.SegmentInfo)} modifySegmentRequest
|
|
130
|
+
* Modify a segment request
|
|
121
131
|
* @property {function(shaka.extern.Manifest):!Promise} filter
|
|
122
132
|
* Should be called when new variants or text streams are added to the
|
|
123
133
|
* Manifest. Note that this operation is asynchronous.
|
|
@@ -150,4 +160,3 @@ shaka.extern.ManifestParser.PlayerInterface;
|
|
|
150
160
|
* @exportDoc
|
|
151
161
|
*/
|
|
152
162
|
shaka.extern.ManifestParser.Factory;
|
|
153
|
-
|
package/externs/shaka/net.js
CHANGED
|
@@ -101,6 +101,7 @@ shaka.extern.Request;
|
|
|
101
101
|
* @typedef {{
|
|
102
102
|
* uri: string,
|
|
103
103
|
* data: BufferSource,
|
|
104
|
+
* status: (number|undefined),
|
|
104
105
|
* headers: !Object.<string, string>,
|
|
105
106
|
* timeMs: (number|undefined),
|
|
106
107
|
* fromCache: (boolean|undefined)
|
|
@@ -119,6 +120,8 @@ shaka.extern.Request;
|
|
|
119
120
|
* redirects, but after request filters are executed.
|
|
120
121
|
* @property {BufferSource} data
|
|
121
122
|
* The body of the response.
|
|
123
|
+
* @property {(number|undefined)} status
|
|
124
|
+
* The response HTTP status code.
|
|
122
125
|
* @property {!Object.<string, string>} headers
|
|
123
126
|
* A map of response headers, if supported by the underlying protocol.
|
|
124
127
|
* All keys should be lowercased.
|
|
@@ -139,15 +142,17 @@ shaka.extern.Response;
|
|
|
139
142
|
* @typedef {!function(string,
|
|
140
143
|
* shaka.extern.Request,
|
|
141
144
|
* shaka.net.NetworkingEngine.RequestType,
|
|
142
|
-
* shaka.extern.ProgressUpdated
|
|
145
|
+
* shaka.extern.ProgressUpdated,
|
|
146
|
+
* shaka.extern.HeadersReceived):
|
|
143
147
|
* !shaka.extern.IAbortableOperation.<shaka.extern.Response>}
|
|
144
148
|
* @description
|
|
145
149
|
* Defines a plugin that handles a specific scheme.
|
|
146
150
|
*
|
|
147
151
|
* The functions accepts four parameters, uri string, request, request type,
|
|
148
|
-
* and a
|
|
149
|
-
*
|
|
150
|
-
* by
|
|
152
|
+
* a progressUpdated function, and a headersReceived function. The
|
|
153
|
+
* progressUpdated and headersReceived functions can be ignored by plugins that
|
|
154
|
+
* do not have this information, but it will always be provided by
|
|
155
|
+
* NetworkingEngine.
|
|
151
156
|
*
|
|
152
157
|
* @exportDoc
|
|
153
158
|
*/
|
|
@@ -171,6 +176,17 @@ shaka.extern.SchemePlugin;
|
|
|
171
176
|
shaka.extern.ProgressUpdated;
|
|
172
177
|
|
|
173
178
|
|
|
179
|
+
/**
|
|
180
|
+
* @typedef {function(!Object.<string, string>)}
|
|
181
|
+
*
|
|
182
|
+
* @description
|
|
183
|
+
* A callback function to handle headers received events through networking
|
|
184
|
+
* engine in player.
|
|
185
|
+
* The first argument is the headers object of the response.
|
|
186
|
+
*/
|
|
187
|
+
shaka.extern.HeadersReceived;
|
|
188
|
+
|
|
189
|
+
|
|
174
190
|
/**
|
|
175
191
|
* Defines a filter for requests. This filter takes the request and modifies
|
|
176
192
|
* it before it is sent to the scheme plugin.
|
package/externs/shaka/offline.js
CHANGED
|
@@ -33,7 +33,8 @@ shaka.extern.OfflineSupport;
|
|
|
33
33
|
* size: number,
|
|
34
34
|
* expiration: number,
|
|
35
35
|
* tracks: !Array.<shaka.extern.Track>,
|
|
36
|
-
* appMetadata: Object
|
|
36
|
+
* appMetadata: Object,
|
|
37
|
+
* isIncomplete: boolean
|
|
37
38
|
* }}
|
|
38
39
|
*
|
|
39
40
|
* @property {?string} offlineUri
|
|
@@ -53,6 +54,9 @@ shaka.extern.OfflineSupport;
|
|
|
53
54
|
* The tracks that are stored.
|
|
54
55
|
* @property {Object} appMetadata
|
|
55
56
|
* The metadata passed to store().
|
|
57
|
+
* @property {boolean} isIncomplete
|
|
58
|
+
* If true, the content is still downloading. Manifests with this set cannot
|
|
59
|
+
* be played yet.
|
|
56
60
|
* @exportDoc
|
|
57
61
|
*/
|
|
58
62
|
shaka.extern.StoredContent;
|
|
@@ -68,7 +72,8 @@ shaka.extern.StoredContent;
|
|
|
68
72
|
* streams: !Array.<shaka.extern.StreamDB>,
|
|
69
73
|
* sessionIds: !Array.<string>,
|
|
70
74
|
* drmInfo: ?shaka.extern.DrmInfo,
|
|
71
|
-
* appMetadata: Object
|
|
75
|
+
* appMetadata: Object,
|
|
76
|
+
* isIncomplete: (boolean|undefined)
|
|
72
77
|
* }}
|
|
73
78
|
*
|
|
74
79
|
* @property {number} creationTime
|
|
@@ -91,6 +96,8 @@ shaka.extern.StoredContent;
|
|
|
91
96
|
* The DRM info used to initialize EME.
|
|
92
97
|
* @property {Object} appMetadata
|
|
93
98
|
* A metadata object passed from the application.
|
|
99
|
+
* @property {(boolean|undefined)} isIncomplete
|
|
100
|
+
* If true, the content is still downloading.
|
|
94
101
|
*/
|
|
95
102
|
shaka.extern.ManifestDB;
|
|
96
103
|
|
|
@@ -195,6 +202,8 @@ shaka.extern.StreamDB;
|
|
|
195
202
|
* appendWindowEnd: number,
|
|
196
203
|
* timestampOffset: number,
|
|
197
204
|
* tilesLayout: ?string,
|
|
205
|
+
* pendingSegmentRefId: (string|undefined),
|
|
206
|
+
* pendingInitSegmentRefId: (string|undefined),
|
|
198
207
|
* dataKey: number
|
|
199
208
|
* }}
|
|
200
209
|
*
|
|
@@ -215,6 +224,17 @@ shaka.extern.StreamDB;
|
|
|
215
224
|
* The value is a grid-item-dimension consisting of two positive decimal
|
|
216
225
|
* integers in the format: column-x-row ('4x3'). It describes the
|
|
217
226
|
* arrangement of Images in a Grid. The minimum valid LAYOUT is '1x1'.
|
|
227
|
+
* @property {(string|undefined)} pendingSegmentRefId
|
|
228
|
+
* Contains an id that identifies what the segment was, originally. Used to
|
|
229
|
+
* coordinate where segments are stored, during the downloading process.
|
|
230
|
+
* If this field is non-null, it's assumed that the segment is not fully
|
|
231
|
+
* downloaded.
|
|
232
|
+
* @property {(string|undefined)} pendingInitSegmentRefId
|
|
233
|
+
* Contains an id that identifies what the init segment was, originally.
|
|
234
|
+
* Used to coordinate where init segments are stored, during the downloading
|
|
235
|
+
* process.
|
|
236
|
+
* If this field is non-null, it's assumed that the init segment is not fully
|
|
237
|
+
* downloaded.
|
|
218
238
|
* @property {number} dataKey
|
|
219
239
|
* The key to the data in storage.
|
|
220
240
|
*/
|
|
@@ -333,6 +353,15 @@ shaka.extern.StorageCell = class {
|
|
|
333
353
|
*/
|
|
334
354
|
addManifests(manifests) {}
|
|
335
355
|
|
|
356
|
+
/**
|
|
357
|
+
* Updates the given manifest, stored at the given key.
|
|
358
|
+
*
|
|
359
|
+
* @param {number} key
|
|
360
|
+
* @param {!shaka.extern.ManifestDB} manifest
|
|
361
|
+
* @return {!Promise}
|
|
362
|
+
*/
|
|
363
|
+
updateManifest(key, manifest) {}
|
|
364
|
+
|
|
336
365
|
/**
|
|
337
366
|
* Replace the expiration time of the manifest stored under |key| with
|
|
338
367
|
* |newExpiration|. If no manifest is found under |key| then this should
|