shaka-player 4.6.6 → 4.6.8
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/CHANGELOG.md +34 -0
- package/README.md +3 -1
- package/demo/main.js +11 -1
- package/dist/demo.compiled.debug.js +30 -30
- package/dist/demo.compiled.debug.map +2 -2
- package/dist/demo.compiled.js +30 -30
- package/dist/demo.compiled.map +2 -2
- package/dist/locales.js +30 -30
- package/dist/shaka-player.compiled.d.ts +4 -0
- package/dist/shaka-player.compiled.debug.d.ts +4 -0
- package/dist/shaka-player.compiled.debug.externs.js +5 -0
- package/dist/shaka-player.compiled.debug.js +82 -80
- package/dist/shaka-player.compiled.debug.map +3 -3
- package/dist/shaka-player.compiled.externs.js +5 -0
- package/dist/shaka-player.compiled.js +775 -775
- package/dist/shaka-player.compiled.map +2 -2
- package/dist/shaka-player.ui.d.ts +4 -0
- package/dist/shaka-player.ui.debug.d.ts +4 -0
- package/dist/shaka-player.ui.debug.externs.js +5 -0
- package/dist/shaka-player.ui.debug.js +102 -99
- package/dist/shaka-player.ui.debug.map +3 -3
- package/dist/shaka-player.ui.externs.js +5 -0
- package/dist/shaka-player.ui.js +923 -923
- package/dist/shaka-player.ui.map +2 -2
- package/lib/ads/client_side_ad.js +13 -2
- package/lib/ads/client_side_ad_manager.js +8 -5
- package/lib/cea/cea608_memory.js +1 -1
- package/lib/cea/cea_decoder.js +1 -1
- package/lib/hls/hls_parser.js +26 -1
- package/lib/media/media_source_engine.js +3 -3
- package/lib/media/presentation_timeline.js +11 -0
- package/lib/net/networking_utils.js +3 -1
- package/lib/offline/session_deleter.js +0 -8
- package/lib/player.js +12 -6
- package/lib/text/vtt_text_parser.js +5 -0
- package/lib/util/periods.js +5 -0
- package/package.json +1 -1
- package/test/cea/cea_decoder_unit.js +36 -0
- package/test/media/media_source_engine_unit.js +24 -1
- package/test/player_load_graph_integration.js +5 -0
- package/test/player_unit.js +17 -0
- package/test/util/periods_unit.js +49 -0
- package/ui/play_button.js +17 -0
- package/ui/small_play_button.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [4.6.8](https://github.com/shaka-project/shaka-player/compare/v4.6.7...v4.6.8) (2024-01-11)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **Ads:** Fix muting/unmuting ads won't affect video and vice versa ([#6073](https://github.com/shaka-project/shaka-player/issues/6073)) ([71f7c57](https://github.com/shaka-project/shaka-player/commit/71f7c57b7fade6f3261c44f2836b9f8adb26edfa))
|
|
9
|
+
* fix handling of multiple CC tracks ([#6076](https://github.com/shaka-project/shaka-player/issues/6076)) ([215b204](https://github.com/shaka-project/shaka-player/commit/215b2046f158d9065a5ffc33a59979af035f38af))
|
|
10
|
+
* **HLS:** getPlayheadTimeAsDate() differs from X-EXT-PROGRAM-DATE-TIME ([#6059](https://github.com/shaka-project/shaka-player/issues/6059)) ([7d41ddc](https://github.com/shaka-project/shaka-player/commit/7d41ddc27510ff310ea6a4760ff5a17b7e8bbc0a))
|
|
11
|
+
* **offline:** Fix server certificate error when trying to delete stored content ([#6080](https://github.com/shaka-project/shaka-player/issues/6080)) ([fd770ad](https://github.com/shaka-project/shaka-player/commit/fd770ad51f55416e9d1e1cc729d1b88795e18d8c))
|
|
12
|
+
* **UI:** Fix replay button when the post-roll is running using CS ([#6072](https://github.com/shaka-project/shaka-player/issues/6072)) ([6c8b700](https://github.com/shaka-project/shaka-player/commit/6c8b700806c845edb4bcd78256f85e8d4bc70485))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Performance Improvements
|
|
16
|
+
|
|
17
|
+
* Improve performance of addThumbnailsTrack ([#6067](https://github.com/shaka-project/shaka-player/issues/6067)) ([8d29cff](https://github.com/shaka-project/shaka-player/commit/8d29cffa14e907bcfc113421e62b1462b81259c3))
|
|
18
|
+
* **WebVTT:** Improve parsing time for unstyled payloads ([#6066](https://github.com/shaka-project/shaka-player/issues/6066)) ([5740367](https://github.com/shaka-project/shaka-player/commit/5740367a242b48a71545aa09ecc4271a9d1a8d15))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Reverts
|
|
22
|
+
|
|
23
|
+
* Install by default shaka.polyfill.PatchedMediaKeysApple when there is no unprefixed EME support ([#6068](https://github.com/shaka-project/shaka-player/issues/6068)) ([8747403](https://github.com/shaka-project/shaka-player/commit/8747403a9b889211a223474b2f04485d665dd211))
|
|
24
|
+
|
|
25
|
+
## [4.6.7](https://github.com/shaka-project/shaka-player/compare/v4.6.6...v4.6.7) (2024-01-09)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* **Ads:** Fix VMAP won't play in muted autoplay ([#6046](https://github.com/shaka-project/shaka-player/issues/6046)) ([2ee7389](https://github.com/shaka-project/shaka-player/commit/2ee73894c8f685167c519d0d9c666647bd6d5a8a))
|
|
31
|
+
* **Demo:** Allow play MP4 and TS in legacy iOS devices ([#6051](https://github.com/shaka-project/shaka-player/issues/6051)) ([daf667a](https://github.com/shaka-project/shaka-player/commit/daf667a1cbba2c0b0dfcbb0192254912ab9b92ca))
|
|
32
|
+
* **HLS:** Live recovery after disconnects ([#6048](https://github.com/shaka-project/shaka-player/issues/6048)) ([44fdb64](https://github.com/shaka-project/shaka-player/commit/44fdb648726f57ba474ca02b257fa94c8891c7a1))
|
|
33
|
+
* Improved HEAD request fail test when fallback-ing to GET request ([#6044](https://github.com/shaka-project/shaka-player/issues/6044)) ([141d3ea](https://github.com/shaka-project/shaka-player/commit/141d3ea4c7f02cc0d22e99da582c20aff78a179a))
|
|
34
|
+
* Install by default shaka.polyfill.PatchedMediaKeysApple when there is no unprefixed EME support ([#6053](https://github.com/shaka-project/shaka-player/issues/6053)) ([7832f1b](https://github.com/shaka-project/shaka-player/commit/7832f1ba4ffd3bccf478113dfad6955603b0ed82))
|
|
35
|
+
* text roles being combined incorrectly in some multiperiod cases ([#6055](https://github.com/shaka-project/shaka-player/issues/6055)) ([f32a769](https://github.com/shaka-project/shaka-player/commit/f32a769bbb5bbcbf3ac65b3fe4802227b2c41274)), closes [#6054](https://github.com/shaka-project/shaka-player/issues/6054)
|
|
36
|
+
|
|
3
37
|
## [4.6.6](https://github.com/shaka-project/shaka-player/compare/v4.6.5...v4.6.6) (2024-01-08)
|
|
4
38
|
|
|
5
39
|
|
package/README.md
CHANGED
|
@@ -302,7 +302,7 @@ Shaka Player supports:
|
|
|
302
302
|
|
|
303
303
|
|
|
304
304
|
## Content Steering support
|
|
305
|
-
Shaka Player supports Content Steering (v1) in DASH.
|
|
305
|
+
Shaka Player supports Content Steering (v1) in DASH and HLS.
|
|
306
306
|
|
|
307
307
|
Content Steering features supported:
|
|
308
308
|
- TTL, if missing, the default value is 300 seconds.
|
|
@@ -316,6 +316,8 @@ Content Steering features **not** supported:
|
|
|
316
316
|
## Documentation & Important Links ##
|
|
317
317
|
|
|
318
318
|
* [Demo](https://shaka-player-demo.appspot.com)([sources](demo/))
|
|
319
|
+
* [Nightly Demo](https://nightly-dot-shaka-player-demo.appspot.com)
|
|
320
|
+
* [Demo index](https://index-dot-shaka-player-demo.appspot.com)
|
|
319
321
|
* [API documentation](https://shaka-player-demo.appspot.com/docs/api/index.html)
|
|
320
322
|
* [Tutorials](https://shaka-player-demo.appspot.com/docs/api/tutorial-welcome.html)
|
|
321
323
|
* [Hosted builds on Google Hosted Libraries](https://developers.google.com/speed/libraries/#shaka-player)
|
package/demo/main.js
CHANGED
|
@@ -738,9 +738,19 @@ shakaDemo.Main = class {
|
|
|
738
738
|
if (asset.features.includes(shakaAssets.Feature.DOLBY_VISION_3D)) {
|
|
739
739
|
mimeTypes.push('video/mp4; codecs="dvh1.20.01"');
|
|
740
740
|
}
|
|
741
|
-
|
|
741
|
+
let hasSupportedMimeType = mimeTypes.some((type) => {
|
|
742
742
|
return this.support_.media[type];
|
|
743
743
|
});
|
|
744
|
+
if (!hasSupportedMimeType &&
|
|
745
|
+
!(window.ManagedMediaSource || window.MediaSource) &&
|
|
746
|
+
!!navigator.vendor && navigator.vendor.includes('Apple')) {
|
|
747
|
+
if (mimeTypes.includes('video/mp4')) {
|
|
748
|
+
hasSupportedMimeType = true;
|
|
749
|
+
}
|
|
750
|
+
if (mimeTypes.includes('video/mp2t')) {
|
|
751
|
+
hasSupportedMimeType = true;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
744
754
|
if (!hasSupportedMimeType) {
|
|
745
755
|
return 'Your browser does not support the required video format.';
|
|
746
756
|
}
|
|
@@ -294,36 +294,36 @@ a.storedContent.offlineUri){const b=this.makeStorageInstance_();if(b){try{a.stor
|
|
|
294
294
|
!0)||this.setupOfflineSupport(b)}}hashChanged_(){this.readHash_();this.dispatchEventWithName_("shaka-main-config-change")}getAssetUnsupportedReason(a,b){if(b&&(!shaka.offline.Storage.support()||!this.initialStoredList_))return"Your browser does not support offline storage.";if(a.source==shakaAssets.Source.CUSTOM)return null;if(a.disabled)return"This asset is disabled.";if(b&&!a.features.includes(shakaAssets.Feature.OFFLINE))return"This asset cannot be downloaded.";if(!a.isClear()&&!a.isAes128()){if(!a.drm.some(c=>
|
|
295
295
|
this.support_.drm[shakaAssets.identifierForKeySystem(c)]))return"Your browser does not support the required key systems.";if(b&&!a.drm.some(c=>{c=shakaAssets.identifierForKeySystem(c);return this.support_.drm[c]&&this.support_.drm[c].persistentState}))return"Your browser does not support offline licenses for the required key systems."}if(a.features.includes(shakaAssets.Feature.DASH)&&!this.support_.manifest["application/dash+xml"])return"Your browser does not support MPEG-DASH manifests.";if(a.features.includes(shakaAssets.Feature.HLS)&&
|
|
296
296
|
!this.support_.manifest["application/x-mpegurl"])return"Your browser does not support HLS manifests.";if(a.features.includes(shakaAssets.Feature.MSS)&&!this.support_.manifest["application/vnd.ms-sstr+xml"])return"Your browser does not support MSS manifests.";b=[];a.features.includes(shakaAssets.Feature.WEBM)&&b.push("video/webm");a.features.includes(shakaAssets.Feature.MP4)&&b.push("video/mp4");a.features.includes(shakaAssets.Feature.MP2TS)&&b.push("video/mp2t");a.features.includes(shakaAssets.Feature.CONTAINERLESS)&&
|
|
297
|
-
b.push("audio/aac");a.features.includes(shakaAssets.Feature.DOLBY_VISION_3D)&&b.push('video/mp4; codecs="dvh1.20.01"');
|
|
298
|
-
a;a=[a].concat(navigator.languages);this.localization_.changeLocale(a)}getUILocale(){return this.uiLocale_}getLastAssetFromHash_(){const a=this.getParams_();var b=a.asset,c=a.adTagUri;if(b){for(const d of shakaAssets.testAssets)if(d.manifestUri==b&&d.adTagUri==c)return d;for(const d of shakaDemoCustom.assets())if(d.manifestUri==b)return d;b=new ShakaDemoAssetInfo("loaded asset","",b,shakaAssets.Source.CUSTOM);
|
|
299
|
-
a.license)}"certificate"in a&&b.addCertificateUri(a.certificate);return b}return null}readHash_(){const a=this.getParams_();if(this.player_){var b=this.player_.getConfiguration();shakaDemo.Utils.runThroughHashParams((d,e)=>{if(d in a){const f=this.getCurrentConfigValue(e);d=a[d];"boolean"==typeof f?d="true"==d:"number"==typeof f&&(d=parseFloat(d));this.configure(e,d)}},b);if(b=
|
|
300
|
-
"videoRobustness"in a&&(b[c].videoRobustness=a.videoRobustness),"audioRobustness"in a&&(b[c].audioRobustness=a.audioRobustness)}"lang"in a&&(c=a.lang,this.configure("preferredAudioLanguage",c),this.configure("preferredTextLanguage",c),this.setUILocale(c));"uilang"in a&&this.setUILocale(a.uilang);"noadaptation"in a&&this.configure("abr.enabled",!1);this.makeVersionLinks_();
|
|
301
|
-
(c=document.getElementById("uncompiled-link"),goog.asserts.assert(c instanceof HTMLAnchorElement,"Wrong element type!"),c.setAttribute("disabled",""),c.removeAttribute("href"),c.title="requires a newer browser");shaka.log&&("vv"in a?shaka.log.setLevel(shaka.log.Level.V2):"v"in a?shaka.log.setLevel(shaka.log.Level.V1):"debug"in a?
|
|
302
|
-
b=a.build:"compiled"in a&&(b="compiled");for(const c of["compiled","debug_compiled","uncompiled"])a=document.getElementById(c.split("_").join("-")+"-link"),goog.asserts.assert(a instanceof HTMLAnchorElement,"Wrong element type!"),b==c?(a.setAttribute("disabled",""),a.removeAttribute("href"),a.title="currently selected"):(a.removeAttribute("disabled"),
|
|
303
|
-
location.reload();return!1}))}getParams_(){var a=location.search.substr(1);a=a?a.split(";"):[];var b=location.hash.substr(1);b=b?b.split(";"):[];b=a.concat(b);a={};for(const c of b)b=c.split("="),a[b[0]]=b.slice(1).join("=");return a}getValueFromGivenConfig_(a,b){for(;a;){const c=a.split(/\.(.+)/);if(3==c.length)a=c[1],
|
|
304
|
-
arguments.length&&"string"==typeof a&&(a=shaka.util.ConfigUtils.convertToConfigObject(a,b));shaka.util.PlayerConfiguration.mergeConfigObjects(this.desiredConfig_,a,this.defaultConfig_);this.player_.configure(a,b)}getConfiguration(){return this.desiredConfig_}async requestCertificate_(a,b){return(await b.request(shaka.net.NetworkingEngine.RequestType.APP,
|
|
305
|
-
this.visualizer_.active;this.visualizer_.active=a;b!=a&&(a?this.visualizer_.start():this.visualizer_.stop())}}unload(){this.visualizer_&&this.visualizer_.stop();this.selectedAsset=null;const a=document.getElementById("video-bar");this.hideElement_(a);this.video_.poster=shakaDemo.Main.mainPoster_;document.fullscreenElement&&document.exitFullscreen();
|
|
306
|
-
window.documentPictureInPicture.window&&window.documentPictureInPicture.window.close();this.player_.unload();this.dispatchEventWithName_("shaka-main-selected-asset-changed");navigator.mediaSession&&(navigator.mediaSession.metadata=null);this.remakeHash()}async drmConfiguration_(a,b){var c=b?b.getNetworkingEngine():this.player_.getNetworkingEngine();
|
|
307
|
-
this.readHash_(),this.player_.configure(d));d=b?b.getConfiguration():this.player_.getConfiguration();if(a.certificateUri){c=await this.requestCertificate_(a.certificateUri,c);c=shaka.util.BufferUtils.toUint8(c);for(const e of a.licenseServers.keys())d.drm.advanced[e]=d.drm.advanced[e]||{},d.drm.advanced[e].serverCertificate=c}else for(const e of a.licenseServers.keys())d.drm.advanced[e]&&
|
|
308
|
-
this.remakeHash()}showPlayer_(){const a=document.getElementById("video-bar");this.showElement_(a);this.closeError_();this.video_.poster=shakaDemo.Main.mainPoster_;a.scrollIntoView({behavior:"smooth",block:"start"})}async loadAsset(a){try{this.selectedAsset=a;this.showPlayer_();this.dispatchEventWithName_("shaka-main-selected-asset-changed");this.nativeControlsEnabled_?(this.controls_.setEnabledShakaControls(!1),
|
|
309
|
-
this.controls_.setEnabledNativeControls(!1),this.player_.setVideoContainer(this.container_));await this.drmConfiguration_(a);this.controls_.getCastProxy().setAppData({asset:a});let b=a.manifestUri;a.storedContent&&a.storedContent.offlineUri&&(b=a.storedContent.offlineUri);if(a.imaAssetKey||a.imaContentSrcId&&a.imaVideoId)b=await this.getManifestUriFromAdManager_(a);a.mediaTailorUrl&&
|
|
310
|
-
(this.video_.poster=shakaDemo.Main.audioOnlyPoster_);for(const d of a.extraText)this.player_.addTextTrackAsync(d.uri,d.language,d.kind,d.mime,d.codecs);for(const d of a.extraThumbnail)this.player_.addThumbnailsTrack(d);for(const d of a.extraChapter)this.player_.addChaptersTrack(d.uri,d.language,d.mime);const c=this.player_.getAdManager();if(c&&a.adTagUri)try{goog.asserts.assert(null!=
|
|
311
|
-
const d=new google.ima.AdsRequest;d.adTagUrl=a.adTagUri;c.requestClientSideAds(d)}catch(d){console.log(d),console.warn("Ads code has been prevented from running. Proceeding without ads.")}if(navigator.mediaSession){const d={title:a.name,artwork:[{src:a.iconUri}]};d.artist=a.source;navigator.mediaSession.metadata=new MediaMetadata(d)}this.visualizer_&&this.visualizer_.active&&this.visualizer_.start()}catch(b){if(b.code==
|
|
312
|
-
[];if(this.player_){var b=this.player_.getConfiguration();shakaDemo.Utils.runThroughHashParams((f,g)=>{const h=this.getCurrentConfigValue(g);g=this.getValueFromGivenConfig_(g,this.defaultConfig_);const l=isNaN(h)&&isNaN(g);h==g||l&&("string"!=typeof h||"string"!=typeof g)||a.push(f+"="+h)},b);if(b=this.getCurrentConfigValue("drm.advanced"))for(var c of shakaDemo.Main.commonDrmSystems){const f=
|
|
313
|
-
f.audioRobustness);break}}}this.getCurrentConfigValue("abr.enabled")||a.push("noadaptation");a.push("uilang="+this.getUILocale());if(this.selectedAsset){c=shakaAssets.testAssets.includes(this.selectedAsset);a.push("asset="+this.selectedAsset.manifestUri);this.selectedAsset.adTagUri&&a.push("adTagUri="+this.selectedAsset.adTagUri);if(!c&&this.selectedAsset.licenseServers.size){b=
|
|
314
|
-
d);break}}!c&&this.selectedAsset.certificateUri&&a.push("certificate="+this.selectedAsset.certificateUri)}d=document.getElementById("nav-button-container");for(var e of d.childNodes)if(e.nodeType==Node.ELEMENT_NODE&&(goog.asserts.assert(e instanceof HTMLElement,"Wrong node type!"),e.classList.contains("mdl-button--accent"))){a.push("panel="+
|
|
315
|
-
"-link").hasAttribute("disabled")&&a.push("build="+f);this.noInput_&&a.push("noinput");this.nativeControlsEnabled_&&a.push("nativecontrols");this.trickPlayControlsEnabled_&&a.push("trickplay");if(shaka.log&&shaka.log.currentLevel!=shaka.log.MAX_LOG_LEVEL)switch(shaka.log.currentLevel){case shaka.log.Level.INFO:a.push("info");
|
|
316
|
-
"",document.location.pathname+"#"+a)}getHamburgerMenu(){return document.getElementById("hamburger-menu-contents")}hideElement_(a){a.classList.add("hidden")}showElement_(a){a.classList.remove("hidden")}async getManifestUriFromAdManager_(a){const b=this.player_.getAdManager(),c=this.controls_.getServerSideAdContainer();
|
|
317
|
-
a.imaAssetKey):(goog.asserts.assert(null!=a.imaContentSrcId&&null!=a.imaVideoId,"Asset should have ima ids!"),d=new google.ima.dai.api.VODStreamRequest,d.contentSourceId=a.imaContentSrcId,d.videoId=a.imaVideoId);switch(a.imaManifestType){case "DASH":case "dash":case "MPD":case "mpd":d.format=google.ima.dai.api.StreamRequest.StreamFormat.DASH;
|
|
318
|
-
console.warn("Ads code has been prevented from running or returned an error. Proceeding without ads."),a.manifestUri}}async getManifestUriFromMediaTailorAdManager_(a){const b=this.player_.getAdManager(),c=this.controls_.getServerSideAdContainer();try{goog.asserts.assert(null!=this.video_,"Video should not be null!");
|
|
319
|
-
d,this.video_);return await b.requestMediaTailorStream(a.mediaTailorUrl,a.mediaTailorAdsParams,a.manifestUri)}catch(d){return console.log(d),console.warn("Ads code has been prevented from running or returned an error. Proceeding without ads."),a.manifestUri}}addNavButton(a){const b=document.getElementById("nav-button-container"),
|
|
320
|
-
d.setAttribute("tab-hash",e):e.panel||(a=null!=d.getAttribute("defaultselected"));const f=document.createElement("div");this.hideElement_(f);c.appendChild(f);e=()=>{for(const g of b.childNodes)g.nodeType==Node.ELEMENT_NODE&&(goog.asserts.assert(g instanceof Element,"Wrong node type!"),g.classList.remove("mdl-button--accent"));
|
|
321
|
-
this.showElement_(f);this.remakeHash();this.dispatchEventWithName_("shaka-main-page-changed");f.scrollIntoView({behavior:"smooth",block:"start"})};d.addEventListener("click",e);a&&Promise.resolve().then(e);return{container:f,button:d}}dispatchEventWithName_(a){const b=document.createEvent("CustomEvent");b.initCustomEvent(a
|
|
322
|
-
e!=d));const c=document.getElementsByClassName("version-string");for(const d of c)d.textContent=a.join("-"),0<b.length&&(d.textContent+=" ("+b.join(", ")+")")}closeError_(){document.getElementById("error-display").classList.add("hidden");this.errorDisplayLink_.href="";this.errorDisplayLink_.textContent="";this.currentErrorSeverity_=
|
|
323
|
-
a.code;let d="";a.code&&(d="../docs/api/shaka.util.Error.html#value:"+a.code);console.error(a);this.handleError_(b,c,d)}handleError_(a,b,c){if(null==this.currentErrorSeverity_||a>this.currentErrorSeverity_)this.errorDisplayLink_.href=c,void 0===this.errorDisplayLink_.textContent?this.errorDisplayLink_.innerText=b:this.errorDisplayLink_.textContent=
|
|
324
|
-
document.getElementById("error-display").classList.remove("hidden")}onCastStatusChange_(a){a&&!this.selectedAsset&&(this.selectedAsset=ShakaDemoAssetInfo.makeBlankAsset(),this.showPlayer_())}static defaultAdvancedDrmConfig(){return{distinctiveIdentifierRequired:!1,persistentStateRequired:!1,videoRobustness:"",audioRobustness:"",
|
|
325
|
-
shakaDemo.Main.commonDrmSystems=["com.widevine.alpha","com.microsoft.playready","com.apple.fps","com.adobe.primetime","org.w3.clearkey"];const shakaDemoMain=new shakaDemo.Main;shakaDemo.Main.mainPoster_="https://shaka-player-demo.appspot.com/assets/poster.jpg";shakaDemo.Main.audioOnlyPoster_="https://shaka-player-demo.appspot.com/assets/audioOnly.gif";
|
|
326
|
-
document.addEventListener("shaka-ui-loaded",()=>{shakaDemo.Main.initWrapper(()=>shakaDemoMain.init())});document.addEventListener("shaka-ui-load-failed",a=>{shakaDemo.Main.initWrapper(()=>{shakaDemoMain.initFailed(a.detail.reasonCode)})});let shakaDemoSearch;
|
|
297
|
+
b.push("audio/aac");a.features.includes(shakaAssets.Feature.DOLBY_VISION_3D)&&b.push('video/mp4; codecs="dvh1.20.01"');a=b.some(c=>this.support_.media[c]);a||window.ManagedMediaSource||window.MediaSource||!navigator.vendor||!navigator.vendor.includes("Apple")||(b.includes("video/mp4")&&(a=!0),b.includes("video/mp2t")&&(a=!0));return a?null:"Your browser does not support the required video format."}setTrickPlayControlsEnabled(a){this.trickPlayControlsEnabled_=a;this.configureUI_();this.remakeHash()}getTrickPlayControlsEnabled(){return this.trickPlayControlsEnabled_}setNativeControlsEnabled(a){this.nativeControlsEnabled_=
|
|
298
|
+
a;this.remakeHash()}getNativeControlsEnabled(){return this.nativeControlsEnabled_}setUILocale(a){this.uiLocale_=a;a=[a].concat(navigator.languages);this.localization_.changeLocale(a)}getUILocale(){return this.uiLocale_}getLastAssetFromHash_(){const a=this.getParams_();var b=a.asset,c=a.adTagUri;if(b){for(const d of shakaAssets.testAssets)if(d.manifestUri==b&&d.adTagUri==c)return d;for(const d of shakaDemoCustom.assets())if(d.manifestUri==b)return d;b=new ShakaDemoAssetInfo("loaded asset","",b,shakaAssets.Source.CUSTOM);
|
|
299
|
+
if("license"in a){c=shakaDemo.Main.commonDrmSystems;"drmSystem"in a&&(c=[a.drmSystem]);for(const d of c)b.addLicenseServer(d,a.license)}"certificate"in a&&b.addCertificateUri(a.certificate);return b}return null}readHash_(){const a=this.getParams_();if(this.player_){var b=this.player_.getConfiguration();shakaDemo.Utils.runThroughHashParams((d,e)=>{if(d in a){const f=this.getCurrentConfigValue(e);d=a[d];"boolean"==typeof f?d="true"==d:"number"==typeof f&&(d=parseFloat(d));this.configure(e,d)}},b);if(b=
|
|
300
|
+
this.getCurrentConfigValue("drm.advanced"))for(var c of shakaDemo.Main.commonDrmSystems)b[c]||(b[c]=shakaDemo.Main.defaultAdvancedDrmConfig()),"videoRobustness"in a&&(b[c].videoRobustness=a.videoRobustness),"audioRobustness"in a&&(b[c].audioRobustness=a.audioRobustness)}"lang"in a&&(c=a.lang,this.configure("preferredAudioLanguage",c),this.configure("preferredTextLanguage",c),this.setUILocale(c));"uilang"in a&&this.setUILocale(a.uilang);"noadaptation"in a&&this.configure("abr.enabled",!1);this.makeVersionLinks_();
|
|
301
|
+
this.nativeControlsEnabled_="nativecontrols"in a;"trickplay"in a&&(this.trickPlayControlsEnabled_=!0,this.configureUI_());shakaDemo.Utils.browserSupportsUncompiledMode()||(c=document.getElementById("uncompiled-link"),goog.asserts.assert(c instanceof HTMLAnchorElement,"Wrong element type!"),c.setAttribute("disabled",""),c.removeAttribute("href"),c.title="requires a newer browser");shaka.log&&("vv"in a?shaka.log.setLevel(shaka.log.Level.V2):"v"in a?shaka.log.setLevel(shaka.log.Level.V1):"debug"in a?
|
|
302
|
+
shaka.log.setLevel(shaka.log.Level.DEBUG):"info"in a&&shaka.log.setLevel(shaka.log.Level.INFO))}makeVersionLinks_(){var a=this.getParams_();let b="uncompiled";"build"in a?b=a.build:"compiled"in a&&(b="compiled");for(const c of["compiled","debug_compiled","uncompiled"])a=document.getElementById(c.split("_").join("-")+"-link"),goog.asserts.assert(a instanceof HTMLAnchorElement,"Wrong element type!"),b==c?(a.setAttribute("disabled",""),a.removeAttribute("href"),a.title="currently selected"):(a.removeAttribute("disabled"),
|
|
303
|
+
a.addEventListener("click",()=>{const d=location.hash.substr(1).split(";").filter(e=>"compiled"!=e&&"build"!=e.split("=")[0]);d.push("build="+c);this.setNewHashSilent_(d.join(";"));location.reload();return!1}))}getParams_(){var a=location.search.substr(1);a=a?a.split(";"):[];var b=location.hash.substr(1);b=b?b.split(";"):[];b=a.concat(b);a={};for(const c of b)b=c.split("="),a[b[0]]=b.slice(1).join("=");return a}getValueFromGivenConfig_(a,b){for(;a;){const c=a.split(/\.(.+)/);if(3==c.length)a=c[1],
|
|
304
|
+
b=b[c[0]];else return b[c[0]]}}getCurrentConfigValue(a){return this.getValueFromGivenConfig_(a,this.desiredConfig_)}resetConfiguration(a){this.configure(a,void 0)}configure(a,b){2==arguments.length&&"string"==typeof a&&(a=shaka.util.ConfigUtils.convertToConfigObject(a,b));shaka.util.PlayerConfiguration.mergeConfigObjects(this.desiredConfig_,a,this.defaultConfig_);this.player_.configure(a,b)}getConfiguration(){return this.desiredConfig_}async requestCertificate_(a,b){return(await b.request(shaka.net.NetworkingEngine.RequestType.APP,
|
|
305
|
+
{uris:[a]}).promise).data}getIsVisualizerActive(){return this.visualizer_?this.visualizer_.active:!1}setIsVisualizerActive(a){if(this.visualizer_){const b=this.visualizer_.active;this.visualizer_.active=a;b!=a&&(a?this.visualizer_.start():this.visualizer_.stop())}}unload(){this.visualizer_&&this.visualizer_.stop();this.selectedAsset=null;const a=document.getElementById("video-bar");this.hideElement_(a);this.video_.poster=shakaDemo.Main.mainPoster_;document.fullscreenElement&&document.exitFullscreen();
|
|
306
|
+
this.video_.webkitDisplayingFullscreen&&this.video_.webkitExitFullscreen();document.pictureInPictureElement&&document.exitPictureInPicture();window.documentPictureInPicture&&window.documentPictureInPicture.window&&window.documentPictureInPicture.window.close();this.player_.unload();this.dispatchEventWithName_("shaka-main-selected-asset-changed");navigator.mediaSession&&(navigator.mediaSession.metadata=null);this.remakeHash()}async drmConfiguration_(a,b){var c=b?b.getNetworkingEngine():this.player_.getNetworkingEngine();
|
|
307
|
+
goog.asserts.assert(c,"There should be a net engine.");a.applyFilters(c);var d=a.getConfiguration();b?b.configure(d):(this.player_.resetConfiguration(),this.readHash_(),this.player_.configure(d));d=b?b.getConfiguration():this.player_.getConfiguration();if(a.certificateUri){c=await this.requestCertificate_(a.certificateUri,c);c=shaka.util.BufferUtils.toUint8(c);for(const e of a.licenseServers.keys())d.drm.advanced[e]=d.drm.advanced[e]||{},d.drm.advanced[e].serverCertificate=c}else for(const e of a.licenseServers.keys())d.drm.advanced[e]&&
|
|
308
|
+
delete d.drm.advanced[e].serverCertificate;b?b.configure(d):this.player_.configure("drm.advanced",d.drm.advanced);this.remakeHash()}showPlayer_(){const a=document.getElementById("video-bar");this.showElement_(a);this.closeError_();this.video_.poster=shakaDemo.Main.mainPoster_;a.scrollIntoView({behavior:"smooth",block:"start"})}async loadAsset(a){try{this.selectedAsset=a;this.showPlayer_();this.dispatchEventWithName_("shaka-main-selected-asset-changed");this.nativeControlsEnabled_?(this.controls_.setEnabledShakaControls(!1),
|
|
309
|
+
this.controls_.setEnabledNativeControls(!0),this.player_.setVideoContainer(null)):(this.controls_.setEnabledShakaControls(!0),this.controls_.setEnabledNativeControls(!1),this.player_.setVideoContainer(this.container_));await this.drmConfiguration_(a);this.controls_.getCastProxy().setAppData({asset:a});let b=a.manifestUri;a.storedContent&&a.storedContent.offlineUri&&(b=a.storedContent.offlineUri);if(a.imaAssetKey||a.imaContentSrcId&&a.imaVideoId)b=await this.getManifestUriFromAdManager_(a);a.mediaTailorUrl&&
|
|
310
|
+
(b=await this.getManifestUriFromMediaTailorAdManager_(a));await this.player_.load(b,null,a.mimeType||void 0);this.player_.isAudioOnly()&&(this.video_.poster=shakaDemo.Main.audioOnlyPoster_);for(const d of a.extraText)this.player_.addTextTrackAsync(d.uri,d.language,d.kind,d.mime,d.codecs);for(const d of a.extraThumbnail)this.player_.addThumbnailsTrack(d);for(const d of a.extraChapter)this.player_.addChaptersTrack(d.uri,d.language,d.mime);const c=this.player_.getAdManager();if(c&&a.adTagUri)try{goog.asserts.assert(null!=
|
|
311
|
+
this.video_,"this.video should exist!");c.initClientSide(this.controls_.getClientSideAdContainer(),this.video_,null);const d=new google.ima.AdsRequest;d.adTagUrl=a.adTagUri;c.requestClientSideAds(d)}catch(d){console.log(d),console.warn("Ads code has been prevented from running. Proceeding without ads.")}if(navigator.mediaSession){const d={title:a.name,artwork:[{src:a.iconUri}]};d.artist=a.source;navigator.mediaSession.metadata=new MediaMetadata(d)}this.visualizer_&&this.visualizer_.active&&this.visualizer_.start()}catch(b){if(b.code==
|
|
312
|
+
shaka.util.Error.Code.LOAD_INTERRUPTED)console.debug("load() interrupted");else this.onError_(b)}this.remakeHash()}remakeHash(){if(this.fullyLoaded_){var a=[];if(this.player_){var b=this.player_.getConfiguration();shakaDemo.Utils.runThroughHashParams((f,g)=>{const h=this.getCurrentConfigValue(g);g=this.getValueFromGivenConfig_(g,this.defaultConfig_);const l=isNaN(h)&&isNaN(g);h==g||l&&("string"!=typeof h||"string"!=typeof g)||a.push(f+"="+h)},b);if(b=this.getCurrentConfigValue("drm.advanced"))for(var c of shakaDemo.Main.commonDrmSystems){const f=
|
|
313
|
+
b[c];if(f){f.videoRobustness&&a.push("videoRobustness="+f.videoRobustness);f.audioRobustness&&a.push("audioRobustness="+f.audioRobustness);break}}}this.getCurrentConfigValue("abr.enabled")||a.push("noadaptation");a.push("uilang="+this.getUILocale());if(this.selectedAsset){c=shakaAssets.testAssets.includes(this.selectedAsset);a.push("asset="+this.selectedAsset.manifestUri);this.selectedAsset.adTagUri&&a.push("adTagUri="+this.selectedAsset.adTagUri);if(!c&&this.selectedAsset.licenseServers.size){b=
|
|
314
|
+
this.selectedAsset.licenseServers.values().next().value;a.push("license="+b);for(var d of this.selectedAsset.licenseServers.keys())if(!shakaDemo.Main.commonDrmSystems.includes(d)){a.push("drmSystem="+d);break}}!c&&this.selectedAsset.certificateUri&&a.push("certificate="+this.selectedAsset.certificateUri)}d=document.getElementById("nav-button-container");for(var e of d.childNodes)if(e.nodeType==Node.ELEMENT_NODE&&(goog.asserts.assert(e instanceof HTMLElement,"Wrong node type!"),e.classList.contains("mdl-button--accent"))){a.push("panel="+
|
|
315
|
+
e.getAttribute("tab-identifier"));(e=e.getAttribute("tab-hash"))&&a.push("panelData="+e);break}for(const f of["compiled","debug_compiled","uncompiled"])document.getElementById(f.split("_").join("-")+"-link").hasAttribute("disabled")&&a.push("build="+f);this.noInput_&&a.push("noinput");this.nativeControlsEnabled_&&a.push("nativecontrols");this.trickPlayControlsEnabled_&&a.push("trickplay");if(shaka.log&&shaka.log.currentLevel!=shaka.log.MAX_LOG_LEVEL)switch(shaka.log.currentLevel){case shaka.log.Level.INFO:a.push("info");
|
|
316
|
+
break;case shaka.log.Level.DEBUG:a.push("debug");break;case shaka.log.Level.V2:a.push("vv");break;case shaka.log.Level.V1:a.push("v")}this.setNewHashSilent_(a.join(";"))}}setNewHashSilent_(a){history.replaceState(null,"",document.location.pathname+"#"+a)}getHamburgerMenu(){return document.getElementById("hamburger-menu-contents")}hideElement_(a){a.classList.add("hidden")}showElement_(a){a.classList.remove("hidden")}async getManifestUriFromAdManager_(a){const b=this.player_.getAdManager(),c=this.controls_.getServerSideAdContainer();
|
|
317
|
+
try{goog.asserts.assert(null!=this.video_,"Video should not be null!");b.initServerSide(c,this.video_);let d;null!=a.imaAssetKey?(d=new google.ima.dai.api.LiveStreamRequest,d.assetKey=a.imaAssetKey):(goog.asserts.assert(null!=a.imaContentSrcId&&null!=a.imaVideoId,"Asset should have ima ids!"),d=new google.ima.dai.api.VODStreamRequest,d.contentSourceId=a.imaContentSrcId,d.videoId=a.imaVideoId);switch(a.imaManifestType){case "DASH":case "dash":case "MPD":case "mpd":d.format=google.ima.dai.api.StreamRequest.StreamFormat.DASH;
|
|
318
|
+
break;case "HLS":case "hls":case "M3U8":case "m3u8":d.format=google.ima.dai.api.StreamRequest.StreamFormat.HLS}return await b.requestServerSideStream(d,a.manifestUri)}catch(d){return console.log(d),console.warn("Ads code has been prevented from running or returned an error. Proceeding without ads."),a.manifestUri}}async getManifestUriFromMediaTailorAdManager_(a){const b=this.player_.getAdManager(),c=this.controls_.getServerSideAdContainer();try{goog.asserts.assert(null!=this.video_,"Video should not be null!");
|
|
319
|
+
goog.asserts.assert(null!=a.mediaTailorUrl,"Media Tailor info not be null!");const d=this.player_.getNetworkingEngine();goog.asserts.assert(d,"There should be a net engine.");b.initMediaTailor(c,d,this.video_);return await b.requestMediaTailorStream(a.mediaTailorUrl,a.mediaTailorAdsParams,a.manifestUri)}catch(d){return console.log(d),console.warn("Ads code has been prevented from running or returned an error. Proceeding without ads."),a.manifestUri}}addNavButton(a){const b=document.getElementById("nav-button-container"),
|
|
320
|
+
c=document.getElementById("contents"),d=document.getElementById("nav-button-"+a);var e=this.getParams_();(a=e.panel==encodeURI(d.getAttribute("tab-identifier")))?(e=e.panelData)&&d.setAttribute("tab-hash",e):e.panel||(a=null!=d.getAttribute("defaultselected"));const f=document.createElement("div");this.hideElement_(f);c.appendChild(f);e=()=>{for(const g of b.childNodes)g.nodeType==Node.ELEMENT_NODE&&(goog.asserts.assert(g instanceof Element,"Wrong node type!"),g.classList.remove("mdl-button--accent"));
|
|
321
|
+
for(const g of c.childNodes)g.nodeType==Node.ELEMENT_NODE&&(goog.asserts.assert(g instanceof Element,"Wrong node type!"),this.hideElement_(g));d.classList.add("mdl-button--accent");this.showElement_(f);this.remakeHash();this.dispatchEventWithName_("shaka-main-page-changed");f.scrollIntoView({behavior:"smooth",block:"start"})};d.addEventListener("click",e);a&&Promise.resolve().then(e);return{container:f,button:d}}dispatchEventWithName_(a){const b=document.createEvent("CustomEvent");b.initCustomEvent(a,
|
|
322
|
+
!1,!1,null);document.dispatchEvent(b)}setUpVersionStrings_(){let a=shaka.Player.version.split("-");const b=[];for(const d of["debug","uncompiled"])a.includes(d)&&(b.push(d),a=a.filter(e=>e!=d));const c=document.getElementsByClassName("version-string");for(const d of c)d.textContent=a.join("-"),0<b.length&&(d.textContent+=" ("+b.join(", ")+")")}closeError_(){document.getElementById("error-display").classList.add("hidden");this.errorDisplayLink_.href="";this.errorDisplayLink_.textContent="";this.currentErrorSeverity_=
|
|
323
|
+
null}onErrorEvent_(a){this.onError_(a.detail)}onError_(a){let b=a.severity;if(null==b||void 0==a.severity)b=shaka.util.Error.Severity.CRITICAL;const c=a.message||"Error code "+a.code;let d="";a.code&&(d="../docs/api/shaka.util.Error.html#value:"+a.code);console.error(a);this.handleError_(b,c,d)}handleError_(a,b,c){if(null==this.currentErrorSeverity_||a>this.currentErrorSeverity_)this.errorDisplayLink_.href=c,void 0===this.errorDisplayLink_.textContent?this.errorDisplayLink_.innerText=b:this.errorDisplayLink_.textContent=
|
|
324
|
+
b,this.currentErrorSeverity_=a,this.errorDisplayLink_.href?this.errorDisplayLink_.classList.remove("input-disabled"):this.errorDisplayLink_.classList.add("input-disabled"),document.getElementById("error-display").classList.remove("hidden")}onCastStatusChange_(a){a&&!this.selectedAsset&&(this.selectedAsset=ShakaDemoAssetInfo.makeBlankAsset(),this.showPlayer_())}static defaultAdvancedDrmConfig(){return{distinctiveIdentifierRequired:!1,persistentStateRequired:!1,videoRobustness:"",audioRobustness:"",
|
|
325
|
+
sessionType:"",serverCertificate:new Uint8Array(0),serverCertificateUri:"",individualizationServer:""}}};shakaDemo.Main.commonDrmSystems=["com.widevine.alpha","com.microsoft.playready","com.apple.fps","com.adobe.primetime","org.w3.clearkey"];const shakaDemoMain=new shakaDemo.Main;shakaDemo.Main.mainPoster_="https://shaka-player-demo.appspot.com/assets/poster.jpg";shakaDemo.Main.audioOnlyPoster_="https://shaka-player-demo.appspot.com/assets/audioOnly.gif";
|
|
326
|
+
shakaDemo.Main.initWrapper=async a=>{try{await a()}catch(b){shakaDemoMain.onError_(b),console.error(b)}};document.addEventListener("shaka-ui-loaded",()=>{shakaDemo.Main.initWrapper(()=>shakaDemoMain.init())});document.addEventListener("shaka-ui-load-failed",a=>{shakaDemo.Main.initWrapper(()=>{shakaDemoMain.initFailed(a.detail.reasonCode)})});let shakaDemoSearch;
|
|
327
327
|
shakaDemo.Search=class{static init(){const a=shakaDemoMain.addNavButton("search");shakaDemoSearch=new shakaDemo.Search(a.container,a.button)}constructor(a,b){this.desiredFeatures_=[];this.button_=b;this.resultsDiv_=document.createElement("div");this.assetCards_=[];document.addEventListener("shaka-main-selected-asset-changed",()=>{this.updateSelected_()});document.addEventListener("shaka-main-offline-progress",()=>{this.updateOfflineProgress_()});document.addEventListener("shaka-main-page-changed",()=>
|
|
328
328
|
{this.resultsDiv_.childNodes.length||a.classList.contains("hidden")||this.remakeResultsDiv_()});this.readHashParameters_();this.updateHashParameters_();this.remakeSearchDiv_(a)}readHashParameters_(){var a=this.button_.getAttribute("tab-hash");if(a)for(const b of a.split(","))if(b.startsWith("drm:")){if(a=b.split("drm:")[1],a=shakaAssets.KeySystem[a])this.desiredDRM_=a}else if(b.startsWith("source:")){if(a=b.split("source:")[1],a=shakaAssets.Source[a])this.desiredSource_=a}else(a=shakaAssets.Feature[b])&&
|
|
329
329
|
this.desiredFeatures_.push(a)}updateHashParameters_(){const a=[];if(this.desiredSource_)for(const b in shakaAssets.Source)shakaAssets.Source[b]==this.desiredSource_&&a.push("source:"+b);if(this.desiredDRM_)for(const b in shakaAssets.KeySystem)shakaAssets.KeySystem[b]==this.desiredDRM_&&a.push("drm:"+b);for(const b of this.desiredFeatures_)for(const c in shakaAssets.Feature)shakaAssets.Feature[c]==b&&a.push(c);0<a.length?this.button_.setAttribute("tab-hash",a.join(",")):this.button_.removeAttribute("tab-hash");
|