shaka-player 2.5.1 → 2.5.5
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/.csslintrc +13 -0
- package/AUTHORS +3 -0
- package/CHANGELOG.md +156 -0
- package/CONTRIBUTORS +3 -0
- package/README.md +3 -0
- package/build/README.md +5 -5
- package/build/apps.py +3 -1
- package/build/build.py +5 -2
- package/build/check.py +17 -0
- package/build/compiler.py +49 -0
- package/build/conformance.textproto +1 -0
- package/build/docs.py +0 -6
- package/build/generateExterns.js +72 -20
- package/build/install-linux-prereqs.sh +4 -4
- package/build/shakaBuildHelpers.py +7 -8
- package/build/test.py +21 -9
- package/build/types/core +1 -0
- package/build/types/ui +6 -1
- package/demo/asset_card.js +129 -41
- package/demo/cast_receiver/receiver_app.css +27 -13
- package/demo/close_button.js +10 -15
- package/demo/common/asset.js +6 -6
- package/demo/common/assets.js +72 -14
- package/demo/config.js +28 -25
- package/demo/custom.js +20 -16
- package/demo/demo.less +107 -16
- package/demo/demo_uncompiled.js +33 -0
- package/demo/demo_utils.js +4 -3
- package/demo/front.js +12 -8
- package/demo/index.html +14 -17
- package/demo/input.js +30 -23
- package/demo/input_container.js +15 -11
- package/demo/load.js +5 -7
- package/demo/main.js +138 -49
- package/demo/search.js +40 -36
- package/demo/service_worker.js +1 -1
- package/demo/tooltip.js +16 -24
- package/dist/.csslintstamp +0 -0
- package/dist/controls.css +1 -1
- package/dist/controls.css.map +1 -1
- package/dist/demo.compiled.debug.js +165 -152
- package/dist/demo.compiled.debug.map +4 -4
- package/dist/demo.compiled.js +165 -152
- package/dist/demo.compiled.map +4 -4
- package/dist/demo.css +1 -1
- package/dist/demo.css.map +1 -1
- package/dist/deps.js +28 -11
- package/dist/receiver.compiled.debug.js +11 -11
- package/dist/receiver.compiled.debug.map +3 -3
- package/dist/receiver.compiled.js +11 -11
- package/dist/receiver.compiled.map +3 -3
- package/dist/shaka-player.compiled.debug.externs.js +232 -102
- package/dist/shaka-player.compiled.debug.js +189 -165
- package/dist/shaka-player.compiled.debug.map +4 -4
- package/dist/shaka-player.compiled.externs.js +232 -102
- package/dist/shaka-player.compiled.js +567 -553
- package/dist/shaka-player.compiled.map +4 -4
- package/dist/shaka-player.ui.debug.externs.js +338 -113
- package/dist/shaka-player.ui.debug.js +296 -276
- package/dist/shaka-player.ui.debug.map +4 -4
- package/dist/shaka-player.ui.externs.js +338 -113
- package/dist/shaka-player.ui.js +685 -671
- package/dist/shaka-player.ui.map +4 -4
- package/docs/tutorials/drm-config.md +1 -0
- package/docs/tutorials/fairplay.md +77 -0
- package/docs/tutorials/index.json +1 -0
- package/docs/tutorials/manifest-parser.md +1 -1
- package/docs/tutorials/ui-customization.md +5 -2
- package/docs/tutorials/ui.md +10 -4
- package/docs/tutorials/welcome.md +2 -2
- package/externs/mediasession.js +16 -1
- package/externs/shaka/net.js +14 -4
- package/externs/shaka/player.js +136 -90
- package/externs/tippy.js +30 -0
- package/externs/webkitmediakeys.js +4 -0
- package/karma.conf.js +30 -24
- package/lib/cast/cast_proxy.js +94 -23
- package/lib/cast/cast_receiver.js +8 -1
- package/lib/dash/content_protection.js +33 -1
- package/lib/dash/dash_parser.js +13 -5
- package/lib/hls/hls_parser.js +20 -4
- package/lib/media/drm_engine.js +29 -2
- package/lib/media/media_source_engine.js +9 -6
- package/lib/media/play_rate_controller.js +14 -3
- package/lib/media/playhead.js +8 -3
- package/lib/media/streaming_engine.js +68 -20
- package/lib/media/transmuxer.js +2 -2
- package/lib/media/video_wrapper.js +8 -3
- package/lib/net/data_uri_plugin.js +5 -2
- package/lib/net/http_fetch_plugin.js +3 -3
- package/lib/net/http_plugin_utils.js +2 -4
- package/lib/net/http_xhr_plugin.js +2 -2
- package/lib/net/networking_engine.js +1 -0
- package/lib/offline/offline_scheme.js +7 -2
- package/lib/player.js +18 -8
- package/lib/polyfill/input_event.js +7 -11
- package/lib/polyfill/mediasource.js +1 -1
- package/lib/polyfill/patchedmediakeys_apple.js +2 -72
- package/lib/text/cue.js +1 -1
- package/lib/text/ttml_text_parser.js +1 -1
- package/lib/util/config_utils.js +1 -0
- package/lib/util/error.js +45 -11
- package/lib/util/event_manager.js +211 -100
- package/lib/util/fairplay_utils.js +122 -0
- package/lib/util/i_releasable.js +1 -0
- package/lib/util/player_configuration.js +7 -0
- package/lib/util/pssh.js +41 -0
- package/lib/util/string_utils.js +42 -6
- package/lib/util/timer.js +1 -1
- package/package.json +33 -33
- package/roadmap.md +96 -0
- package/shaka-player.uncompiled.js +5 -1
- package/test/dash/dash_parser_content_protection_unit.js +35 -1
- package/test/dash/dash_parser_manifest_unit.js +60 -0
- package/test/hls/hls_live_unit.js +7 -1
- package/test/hls/hls_parser_unit.js +50 -0
- package/test/media/drm_engine_unit.js +10 -4
- package/test/media/media_source_engine_integration.js +12 -0
- package/test/media/media_source_engine_unit.js +3 -1
- package/test/media/playhead_unit.js +7 -5
- package/test/media/streaming_engine_unit.js +46 -1
- package/test/media/transmuxer_integration.js +13 -0
- package/test/net/data_uri_plugin_unit.js +13 -2
- package/test/net/http_plugin_unit.js +17 -12
- package/test/net/networking_engine_unit.js +17 -8
- package/test/offline/offline_scheme_unit.js +18 -8
- package/test/player_external.js +3 -2
- package/test/player_integration.js +94 -3
- package/test/player_src_equals_integration.js +2 -2
- package/test/player_unit.js +21 -8
- package/test/test/boot.js +20 -5
- package/test/test/externs/jasmine.js +48 -0
- package/test/test/util/expect_async_polyfill.js +145 -0
- package/test/test/util/fake_networking_engine.js +1 -0
- package/test/test/util/manifest_generator.js +2 -1
- package/test/test/util/test_scheme.js +34 -2
- package/test/test/util/ui_utils.js +41 -0
- package/test/test/util/util.js +16 -8
- package/test/ui/ui_unit.js +130 -4
- package/ui/audio_language_selection.js +17 -96
- package/ui/big_play_button.js +61 -0
- package/ui/controls.js +226 -335
- package/ui/controls.less +3 -5
- package/ui/element.js +24 -6
- package/ui/externs/ui.js +62 -9
- package/ui/fullscreen_button.js +2 -52
- package/ui/less/buttons.less +10 -16
- package/ui/less/containers.less +75 -20
- package/ui/less/general.less +18 -2
- package/ui/less/other_elements.less +2 -1
- package/ui/less/overflow_menu.less +11 -10
- package/ui/less/range_elements.less +12 -10
- package/ui/less/spinner.less +2 -0
- package/ui/overflow_menu.js +1 -1
- package/ui/pip_button.js +1 -1
- package/ui/{play_pause_button.js → play_button.js} +17 -47
- package/ui/presentation_time.js +17 -12
- package/ui/range_element.js +176 -0
- package/ui/resolution_selection.js +43 -106
- package/ui/seek_bar.js +204 -0
- package/ui/settings_menu.js +113 -0
- package/ui/small_play_button.js +73 -0
- package/ui/text_displayer.js +17 -14
- package/ui/text_selection.js +42 -107
- package/ui/ui.js +17 -40
- package/ui/volume_bar.js +40 -68
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# FairPlay Support
|
|
2
|
+
|
|
3
|
+
When using native `src=` playback, we support using FairPlay on Safari.
|
|
4
|
+
Adding FairPlay support involves a bit more work than other key systems.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Server certificate
|
|
8
|
+
|
|
9
|
+
All FairPlay content requires setting a server certificate. This is set in the
|
|
10
|
+
Player configuration:
|
|
11
|
+
|
|
12
|
+
```js
|
|
13
|
+
const req = await fetch('https://example.com/cert.der');
|
|
14
|
+
const cert = await req.arrayBuffer();
|
|
15
|
+
|
|
16
|
+
player.configure('drm.advanced.com\\.apple\\.fps\\.1_0.serverCertificate',
|
|
17
|
+
new Uint8Array(cert));
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Content ID
|
|
22
|
+
|
|
23
|
+
Some FairPlay content use custom signaling for the content ID. The content ID
|
|
24
|
+
is used by the browser to generate the license request. If you don't use the
|
|
25
|
+
default content ID derivation, you need to specify a custom init data transform:
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
player.configure('drm.initDataTransform', (initData) => {
|
|
29
|
+
const contentId = getMyContentId(initData);
|
|
30
|
+
const cert = player.drmInfo().serverCertificate;
|
|
31
|
+
return shaka.util.FairPlayUtils.initDataTransform(initData, contentId, cert);
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## License wrapping
|
|
36
|
+
|
|
37
|
+
For v2.5.x, we provide a default license request/response filter that mirrors
|
|
38
|
+
the FairPlay examples. You can remove these by setting the
|
|
39
|
+
`drm.fairPlayTransform` configuration to `false`.
|
|
40
|
+
|
|
41
|
+
Some FairPlay servers need to accept the license request in a different format
|
|
42
|
+
or give the response in a different format. For more info, see the general
|
|
43
|
+
{@tutorial license-wrapping} tutorial:
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
player.getNetworkingEngine().registerRequestFilter((type, request) => {
|
|
47
|
+
if (type != shaka.net.NetworkingEngine.RequestType.LICENSE) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const originalPayload = new Uint8Array(request.body);
|
|
52
|
+
const base64Payload =
|
|
53
|
+
shaka.util.Uint8ArrayUtils.toStandardBase64(originalPayload);
|
|
54
|
+
const params = 'spc=' + base64Payload;
|
|
55
|
+
request.headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
56
|
+
request.body = shaka.util.StringUtils.toUTF8(encodeURIComponent(params));
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
player.getNetworkingEngine().registerResponseFilter((type, request) => {
|
|
60
|
+
if (type != shaka.net.NetworkingEngine.RequestType.LICENSE) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let responseText = shaka.util.StringUtils.fromUTF8(response.data);
|
|
65
|
+
// Trim whitespace.
|
|
66
|
+
responseText = responseText.trim();
|
|
67
|
+
|
|
68
|
+
// Look for <ckc> wrapper and remove it.
|
|
69
|
+
if (responseText.substr(0, 5) === '<ckc>' &&
|
|
70
|
+
responseText.substr(-6) === '</ckc>') {
|
|
71
|
+
responseText = responseText.slice(5, -6);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Decode the base64-encoded data into the format the browser expects.
|
|
75
|
+
response.data = shaka.util.Uint8ArrayUtils.fromBase64(responseText).buffer;
|
|
76
|
+
});
|
|
77
|
+
```
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
{ "architecture": { "title": "Architecture Diagrams" } },
|
|
16
16
|
{ "service-worker": { "title": "Service Worker Caching" } },
|
|
17
17
|
{ "offline": { "title": "Offline Storage and Playback" } },
|
|
18
|
+
{ "fairplay": { "title": "FairPlay support" } },
|
|
18
19
|
{ "faq": { "title": "Frequently Asked Questions" } },
|
|
19
20
|
{ "upgrade": {
|
|
20
21
|
"title": "Upgrade Guide",
|
|
@@ -216,7 +216,7 @@ In order to support Live content, the manifest may need to be updated. In the
|
|
|
216
216
|
`setInterval`) to update the manifest. Then it should re-parse the manifest
|
|
217
217
|
periodically. To add new segments to the streams, simply add them to the
|
|
218
218
|
segment index. Because the original manifest object is modified in-place,
|
|
219
|
-
adding them to the index will allow the Player to use them. You *
|
|
219
|
+
adding them to the index will allow the Player to use them. You *cannot* add
|
|
220
220
|
new Variants or text streams to an existing Period.
|
|
221
221
|
|
|
222
222
|
To add a new Period, you must first call `filterNewPeriod`. This will filter out
|
|
@@ -68,6 +68,9 @@ The following buttons can be added to the overflow menu:
|
|
|
68
68
|
that support it. Button is invisible on other browsers.
|
|
69
69
|
<!-- TODO: If we add more buttons that can be put in the order this way, list them here. -->
|
|
70
70
|
|
|
71
|
+
The presense of the seek bar and the big play button in the center of the video element can be
|
|
72
|
+
customized with `addSeekBar` and `addBigPlayButton` booleans in the config.
|
|
73
|
+
|
|
71
74
|
UI layout can be reconfigured at any point after it's been created.
|
|
72
75
|
Please note that custom layouts might need CSS adjustments to look good.
|
|
73
76
|
|
|
@@ -75,8 +78,8 @@ Please note that custom layouts might need CSS adjustments to look good.
|
|
|
75
78
|
<!-- TODO: Is there a better way to do this? (The actual thing, not the tutorial) -->
|
|
76
79
|
The seek bar consists of three segments: past (already played part of the presentation),
|
|
77
80
|
future-buffered and future-unbuffered. The segments colors are set when the seek bar is created.
|
|
78
|
-
To customize the colors, change the values of `shaka.ui.
|
|
79
|
-
`shaka.ui.
|
|
81
|
+
To customize the colors, change the values of `shaka.ui.Constants.SEEK_BAR_BASE_COLOR` ,
|
|
82
|
+
`shaka.ui.Constants.SEEK_BAR_PLAYED_COLOR`, and `shaka.ui.Constants.SEEK_BAR_BUFFERED_COLOR` in ui/controls.js
|
|
80
83
|
|
|
81
84
|
|
|
82
85
|
#### Creating custom elements and adding them to the UI
|
package/docs/tutorials/ui.md
CHANGED
|
@@ -19,6 +19,8 @@ Set up controls with HTML data attributes:
|
|
|
19
19
|
<script src="dist/shaka-player.ui.js"></script>
|
|
20
20
|
<!-- Shaka Player ui compiled library default CSS: -->
|
|
21
21
|
<link rel="stylesheet" type="text/css" href="dist/controls.css">
|
|
22
|
+
<!-- Chromecast SDK (if you want Chromecast support for your app): -->
|
|
23
|
+
<script defer src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js"></script>
|
|
22
24
|
<!-- Your application source: -->
|
|
23
25
|
<script src="myapp.js"></script>
|
|
24
26
|
</head>
|
|
@@ -27,7 +29,7 @@ Set up controls with HTML data attributes:
|
|
|
27
29
|
The data-shaka-player-cast-receiver-id tag allows you to provide a Cast Application ID that
|
|
28
30
|
the cast button will cast to; the value provided here is the sample cast receiver. -->
|
|
29
31
|
<div data-shaka-player-container style="max-width:40em"
|
|
30
|
-
data-shaka-player-cast-receiver-id="
|
|
32
|
+
data-shaka-player-cast-receiver-id="7B25EC44">
|
|
31
33
|
<!-- The data-shaka-player tag will make the UI library use this video element.
|
|
32
34
|
If no video is provided, the UI will automatically make one inside the container div. -->
|
|
33
35
|
<video autoplay data-shaka-player id="video" style="width:100%;height:100%"></video>
|
|
@@ -60,7 +62,7 @@ async function init() {
|
|
|
60
62
|
// This runs if the asynchronous load is successful.
|
|
61
63
|
console.log('The video has now been loaded!');
|
|
62
64
|
} catch (error) {
|
|
63
|
-
|
|
65
|
+
onPlayerError(error);
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
|
|
@@ -71,21 +73,24 @@ function onPlayerErrorEvent(errorEvent) {
|
|
|
71
73
|
|
|
72
74
|
function onPlayerError(error) {
|
|
73
75
|
// Handle player error
|
|
76
|
+
console.error('Error code', error.code, 'object', error);
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
function onUIErrorEvent(errorEvent) {
|
|
77
|
-
//
|
|
80
|
+
// Extract the shaka.util.Error object from the event.
|
|
81
|
+
onPlayerError(event.detail);
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
function initFailed() {
|
|
81
85
|
// Handle the failure to load
|
|
86
|
+
console.error('Unable to load the UI library!');
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
// Listen to the custom shaka-ui-loaded event, to wait until the UI is loaded.
|
|
85
90
|
document.addEventListener('shaka-ui-loaded', init);
|
|
86
91
|
// Listen to the custom shaka-ui-load-failed event, in case Shaka Player fails
|
|
87
92
|
// to load (e.g. due to lack of browser support).
|
|
88
|
-
document.addEventListener('shaka-ui-load-failed, initFailed);
|
|
93
|
+
document.addEventListener('shaka-ui-load-failed', initFailed);
|
|
89
94
|
|
|
90
95
|
```
|
|
91
96
|
|
|
@@ -116,6 +121,7 @@ Next, let's add a listener to the 'caststatuschanged' event in myapp.js:
|
|
|
116
121
|
function onCastStatusChanged(event) {
|
|
117
122
|
const newCastStatus = event['newStatus'];
|
|
118
123
|
// Handle cast status change
|
|
124
|
+
console.log('The new cast status is: ' + newCastStatus);
|
|
119
125
|
}
|
|
120
126
|
|
|
121
127
|
```
|
|
@@ -28,9 +28,9 @@ externs have been generated.
|
|
|
28
28
|
You can build Shaka on Linux, Windows, or Mac.
|
|
29
29
|
To get the sources and compile the library, you will need:
|
|
30
30
|
* {@link https://git-scm.com/downloads Git v1.9+}
|
|
31
|
-
* {@link https://www.python.org/downloads/ Python v2.7}
|
|
31
|
+
* {@link https://www.python.org/downloads/ Python v2.7 or v3.5+}
|
|
32
32
|
* {@link https://java.com/en/download/ Java Runtime Environment v8+}
|
|
33
|
-
* {@link https://nodejs.org/en/download/ NodeJS
|
|
33
|
+
* {@link https://nodejs.org/en/download/ NodeJS v8+}
|
|
34
34
|
* A local web server, such as {@link https://httpd.apache.org/ Apache}
|
|
35
35
|
* _NOTE: A local web server is required because browsers place restrictions
|
|
36
36
|
on applications from file:/// URLs._
|
package/externs/mediasession.js
CHANGED
|
@@ -34,5 +34,20 @@ var MediaMetadata = function(options) {};
|
|
|
34
34
|
MediaMetadata.prototype.title;
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
/** @type {
|
|
37
|
+
/** @type {string} */
|
|
38
|
+
MediaMetadata.prototype.artist;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/** @type {string} */
|
|
42
|
+
MediaMetadata.prototype.artwork;
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
/** @constructor */
|
|
46
|
+
var MediaSession = function() {};
|
|
47
|
+
|
|
48
|
+
/** @type {?MediaMetadata} */
|
|
49
|
+
MediaSession.prototype.metadata;
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
/** @type {MediaSession} */
|
|
38
53
|
Navigator.prototype.mediaSession;
|
package/externs/shaka/net.js
CHANGED
|
@@ -60,7 +60,8 @@ shaka.extern.RetryParameters;
|
|
|
60
60
|
* headers: !Object.<string, string>,
|
|
61
61
|
* allowCrossSiteCredentials: boolean,
|
|
62
62
|
* retryParameters: !shaka.extern.RetryParameters,
|
|
63
|
-
* licenseRequestType: ?string
|
|
63
|
+
* licenseRequestType: ?string,
|
|
64
|
+
* sessionId: ?string
|
|
64
65
|
* }}
|
|
65
66
|
*
|
|
66
67
|
* @description
|
|
@@ -87,6 +88,9 @@ shaka.extern.RetryParameters;
|
|
|
87
88
|
* request it is (not the type of license). This is the |messageType| field
|
|
88
89
|
* of the EME message. For example, this could be 'license-request' or
|
|
89
90
|
* 'license-renewal'.
|
|
91
|
+
* @property {?string} sessionId
|
|
92
|
+
* If this is a LICENSE request, this field contains the session ID of the
|
|
93
|
+
* EME session that made the request.
|
|
90
94
|
*
|
|
91
95
|
* @exportDoc
|
|
92
96
|
*/
|
|
@@ -110,6 +114,9 @@ shaka.extern.Request;
|
|
|
110
114
|
* @property {string} uri
|
|
111
115
|
* The URI which was loaded. Request filters and server redirects can cause
|
|
112
116
|
* this to be different from the original request URIs.
|
|
117
|
+
* @property {string} originalUri
|
|
118
|
+
* The original URI passed to the browser for networking. This is before any
|
|
119
|
+
* redirects, but after request filters are executed.
|
|
113
120
|
* @property {ArrayBuffer} data
|
|
114
121
|
* The body of the response.
|
|
115
122
|
* @property {!Object.<string, string>} headers
|
|
@@ -132,13 +139,16 @@ shaka.extern.Response;
|
|
|
132
139
|
* @typedef {!function(string,
|
|
133
140
|
* shaka.extern.Request,
|
|
134
141
|
* shaka.net.NetworkingEngine.RequestType,
|
|
135
|
-
* shaka.extern.ProgressUpdated
|
|
142
|
+
* shaka.extern.ProgressUpdated):
|
|
136
143
|
* !shaka.extern.IAbortableOperation.<shaka.extern.Response>}
|
|
137
144
|
* @description
|
|
138
145
|
* Defines a plugin that handles a specific scheme.
|
|
146
|
+
*
|
|
139
147
|
* The functions accepts four parameters, uri string, request, request type,
|
|
140
|
-
* and
|
|
141
|
-
|
|
148
|
+
* and a progressUpdated function. The progressUpdated function can be ignored
|
|
149
|
+
* by plugins that do not have this information, but it will always be provided
|
|
150
|
+
* by NetworkingEngine.
|
|
151
|
+
*
|
|
142
152
|
* @exportDoc
|
|
143
153
|
*/
|
|
144
154
|
shaka.extern.SchemePlugin;
|