From 12561c0ed350aa2c4720f2f0e5fce6f8cbea223f Mon Sep 17 00:00:00 2001 From: James Taylor Date: Tue, 31 Aug 2021 17:58:42 -0700 Subject: av-merge: Specify which of MediaSource, audio, or video are unsupported MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jesús --- youtube/static/js/av-merge.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'youtube/static/js') diff --git a/youtube/static/js/av-merge.js b/youtube/static/js/av-merge.js index 8a1deb8..dfbf3c9 100644 --- a/youtube/static/js/av-merge.js +++ b/youtube/static/js/av-merge.js @@ -39,16 +39,26 @@ function AVMerge(video, srcPair, startTime){ this.setup(); } AVMerge.prototype.setup = function() { - if ('MediaSource' in window - && MediaSource.isTypeSupported(this.audioSource['mime_codec']) - && MediaSource.isTypeSupported(this.videoSource['mime_codec'])) { + if (!('MediaSource' in window)) { + reportError('MediaSource not supported.'); + return; + } + var audioSupported = MediaSource.isTypeSupported( + this.audioSource['mime_codec'] + ) + var videoSupported = MediaSource.isTypeSupported( + this.videoSource['mime_codec'] + ) + if (!audioSupported) + reportError('Unsupported MIME type or codec: ', + this.audioSource['mime_codec']); + if (!videoSupported) + reportError('Unsupported MIME type or codec: ', + this.videoSource['mime_codec']); + if (audioSupported && videoSupported) { this.mediaSource = new MediaSource(); this.video.src = URL.createObjectURL(this.mediaSource); this.mediaSource.onsourceopen = this.sourceOpen.bind(this); - } else { - reportError('Unsupported MIME type or codec: ', - this.audioSource['mime_codec'], - this.videoSource['mime_codec']); } } -- cgit v1.2.3