From bd5da6bdcf8dc5aa21585318f73f2b3437724eb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Tue, 10 Aug 2021 19:04:24 +0200 Subject: [PATCH] fix: Add support to file type in MediaCapabilities polyfill (#3569) Issue: #3530 --- 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) {