From 419df0b6cb7ea41b22b38b99b0ecf3b49d93d281 Mon Sep 17 00:00:00 2001 From: Alvaro Velad Date: Mon, 9 Aug 2021 14:25:38 +0200 Subject: [PATCH] Add support to file type in MediaCapabilities polyfill --- lib/polyfill/media_capabilities.js | 45 ++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/lib/polyfill/media_capabilities.js b/lib/polyfill/media_capabilities.js index 7ce154e5ae..346e9ba463 100644 --- a/lib/polyfill/media_capabilities.js +++ b/lib/polyfill/media_capabilities.js @@ -63,21 +63,42 @@ shaka.polyfill.MediaCapabilities = class { return res; } - // Use 'MediaSource.isTypeSupported' to check if the stream is supported. - if (mediaDecodingConfig['video']) { - const contentType = mediaDecodingConfig['video'].contentType; - const isSupported = MediaSource.isTypeSupported(contentType); - if (!isSupported) { - return res; + if (mediaDecodingConfig.type == 'media-source') { + // Use 'MediaSource.isTypeSupported' to check if the stream is supported. + if (mediaDecodingConfig['video']) { + const contentType = mediaDecodingConfig['video'].contentType; + const isSupported = MediaSource.isTypeSupported(contentType); + if (!isSupported) { + return res; + } + } + + if (mediaDecodingConfig['audio']) { + const contentType = mediaDecodingConfig['audio'].contentType; + const isSupported = MediaSource.isTypeSupported(contentType); + if (!isSupported) { + return res; + } + } + } else if (mediaDecodingConfig.type == 'file') { + if (mediaDecodingConfig['video']) { + const contentType = mediaDecodingConfig['video'].contentType; + const isSupported = shaka.util.Platform.supportsMediaType(contentType); + if (!isSupported) { + return res; + } } - } - if (mediaDecodingConfig['audio']) { - const contentType = mediaDecodingConfig['audio'].contentType; - const isSupported = MediaSource.isTypeSupported(contentType); - if (!isSupported) { - return res; + if (mediaDecodingConfig['audio']) { + const contentType = mediaDecodingConfig['audio'].contentType; + const isSupported = shaka.util.Platform.supportsMediaType(contentType); + if (!isSupported) { + return res; + } } + } else { + // Otherwise not supported. + return res; } if (!mediaDecodingConfig.keySystemConfiguration) {