Skip to content

Commit

Permalink
feat(MediaCap): Add config for using MediaCapabilities
Browse files Browse the repository at this point in the history
The developers should be able to set the config to use
MediaCapabilities.
If set to true, we'll use mediaCapabilities.decodingInfo() to
get the variants' decodingInfo.
If set to false, we'll fallback to use
MediaSource.isTypeSupported() and
navigator.requestMediaKeyAccess().

Issue shaka-project#1391

Change-Id: I1acbfb12780291e998d56a91156ae2c47a87c7ae
  • Loading branch information
michellezhuogg committed Mar 23, 2021
1 parent 966a756 commit 129b068
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions demo/common/message_ids.js
Expand Up @@ -225,6 +225,7 @@ shakaDemo.MessageIds = {
TRICK_PLAY_CONTROLS_WARNING: 'DEMO_TRICK_PLAY_CONTROLS_WARNING',
UI_LOCALE: 'DEMO_UI_LOCALE',
UPDATE_EXPIRATION_TIME: 'DEMO_UPDATE_EXPIRATION_TIME',
USE_MEDIA_CAPABILITIES: 'DEMO_USE_MEDIA_CAPABILITIES',
USE_NATIVE_HLS_SAFARI: 'DEMO_USE_NATIVE_HLS_SAFARI',
USE_PERSISTENT_LICENSES: 'DEMO_USE_PERSISTENT_LICENSES',
VIDEO_ROBUSTNESS: 'DEMO_VIDEO_ROBUSTNESS',
Expand Down
4 changes: 3 additions & 1 deletion demo/config.js
Expand Up @@ -334,7 +334,9 @@ shakaDemo.Config = class {
.addBoolInput_(MessageIds.FORCE_HTTPS,
'streaming.forceHTTPS')
.addBoolInput_(MessageIds.PREFER_NATIVE_HLS,
'streaming.preferNativeHls');
'streaming.preferNativeHls')
.addBoolInput_(MessageIds.USE_MEDIA_CAPABILITIES,
'useMediaCapabilities');

if (!shakaDemoMain.getNativeControlsEnabled()) {
this.addBoolInput_(MessageIds.ALWAYS_STREAM_TEXT,
Expand Down
1 change: 1 addition & 0 deletions demo/locales/en.json
Expand Up @@ -125,6 +125,7 @@
"DEMO_MAX_PIXELS": "Max Pixels",
"DEMO_MAX_SMALL_GAP_SIZE": "Maximum Small Gap Size",
"DEMO_MAX_WIDTH": "Max Width",
"DEMO_USE_MEDIA_CAPABILITIES": "Use MediaCapabilities",
"DEMO_MICROSOFT": "Microsoft",
"DEMO_MIN_BANDWIDTH": "Min Bandwidth",
"DEMO_MIN_FRAMERATE": "Min Framerate",
Expand Down
4 changes: 4 additions & 0 deletions demo/locales/source.json
Expand Up @@ -503,6 +503,10 @@
"description": "The name of a configuration value.",
"message": "Max Width"
},
"DEMO_USE_MEDIA_CAPABILITIES": {
"description": "The name of a configuration value.",
"message": "Use [JARGON:MediaCapabilities]"
},
"DEMO_MICROSOFT": {
"description": "Text that describes an asset that comes from the Microsoft.",
"message": "[PROPER_NAME:Microsoft]"
Expand Down
6 changes: 5 additions & 1 deletion externs/shaka/player.js
Expand Up @@ -967,7 +967,8 @@ shaka.extern.OfflineConfiguration;
* restrictions: shaka.extern.Restrictions,
* playRangeStart: number,
* playRangeEnd: number,
* textDisplayFactory: shaka.extern.TextDisplayer.Factory
* textDisplayFactory: shaka.extern.TextDisplayer.Factory,
* useMediaCapabilities: boolean
* }}
*
* @property {shaka.extern.DrmConfiguration} drm
Expand Down Expand Up @@ -1016,6 +1017,9 @@ shaka.extern.OfflineConfiguration;
* @property {shaka.extern.TextDisplayer.Factory} textDisplayFactory
* A factory to construct a text displayer. Note that, if this is changed
* during playback, it will cause the text tracks to be reloaded.
* @property {boolean} useMediaCapabilities
* If true, use MediaCapabilities.decodingInfo() to filter the manifest, and
* get MediaKeys information for encrypted content. Default to false.
* @exportDoc
*/
shaka.extern.PlayerConfiguration;
Expand Down
1 change: 1 addition & 0 deletions lib/util/player_configuration.js
Expand Up @@ -245,6 +245,7 @@ shaka.util.PlayerConfiguration = class {
},
playRangeStart: 0,
playRangeEnd: Infinity,
useMediaCapabilities: false,
textDisplayFactory: () => null,
};

Expand Down

0 comments on commit 129b068

Please sign in to comment.