From c5cb1028aee54ba89f7b79f2046b26747c02ab25 Mon Sep 17 00:00:00 2001 From: matjaz321 Date: Thu, 13 Aug 2020 22:35:04 +0200 Subject: [PATCH 1/8] Added onError eventListener to the youtube iframe video player to destroy itself whenever it receives any errors --- src/plugins/youtubePlayer/plugin.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/youtubePlayer/plugin.js b/src/plugins/youtubePlayer/plugin.js index eed75a8116..c83fac1b82 100644 --- a/src/plugins/youtubePlayer/plugin.js +++ b/src/plugins/youtubePlayer/plugin.js @@ -142,7 +142,11 @@ function setCurrentSrc(instance, elem, options) { } else if (event.data === YT.PlayerState.PAUSED) { events.trigger(instance, 'pause'); } - } + }, + 'onError': () => { + instance.destroy(); + loading.hide(); + }, }, playerVars: { controls: 0, From a50e4853e3206934c1fcaa9a950beb476e3a416f Mon Sep 17 00:00:00 2001 From: matjaz321 Date: Thu, 13 Aug 2020 22:40:01 +0200 Subject: [PATCH 2/8] linting fixes --- src/plugins/youtubePlayer/plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/youtubePlayer/plugin.js b/src/plugins/youtubePlayer/plugin.js index c83fac1b82..7225de5960 100644 --- a/src/plugins/youtubePlayer/plugin.js +++ b/src/plugins/youtubePlayer/plugin.js @@ -146,7 +146,7 @@ function setCurrentSrc(instance, elem, options) { 'onError': () => { instance.destroy(); loading.hide(); - }, + } }, playerVars: { controls: 0, From 865e9085ef8fdc32d6ebcee8aaa68fb2b0a79f2f Mon Sep 17 00:00:00 2001 From: matjaz321 Date: Wed, 19 Aug 2020 21:32:22 +0200 Subject: [PATCH 3/8] CR fixes --- src/components/playback/playbackmanager.js | 4 ++++ src/plugins/youtubePlayer/plugin.js | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/playback/playbackmanager.js b/src/components/playback/playbackmanager.js index 3b4099d540..9959544ae7 100644 --- a/src/components/playback/playbackmanager.js +++ b/src/components/playback/playbackmanager.js @@ -2260,6 +2260,10 @@ class PlaybackManager { }, function () { // TODO: show error message self.stop(player); + loading.hide(); + }).catch(() => { + player.destroy(); + loading.hide(); }); }); } diff --git a/src/plugins/youtubePlayer/plugin.js b/src/plugins/youtubePlayer/plugin.js index 7225de5960..2ac9a63783 100644 --- a/src/plugins/youtubePlayer/plugin.js +++ b/src/plugins/youtubePlayer/plugin.js @@ -143,10 +143,7 @@ function setCurrentSrc(instance, elem, options) { events.trigger(instance, 'pause'); } }, - 'onError': () => { - instance.destroy(); - loading.hide(); - } + 'onError': () => reject(), }, playerVars: { controls: 0, From 73e6f3c03fa7bdb84d90743e645cafa351315a41 Mon Sep 17 00:00:00 2001 From: matjaz321 Date: Wed, 19 Aug 2020 21:35:51 +0200 Subject: [PATCH 4/8] fixed linting error --- src/plugins/youtubePlayer/plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/youtubePlayer/plugin.js b/src/plugins/youtubePlayer/plugin.js index 2ac9a63783..9079e2bcb6 100644 --- a/src/plugins/youtubePlayer/plugin.js +++ b/src/plugins/youtubePlayer/plugin.js @@ -143,7 +143,7 @@ function setCurrentSrc(instance, elem, options) { events.trigger(instance, 'pause'); } }, - 'onError': () => reject(), + 'onError': () => reject() }, playerVars: { controls: 0, From d969fc2cdb1174dce15d7121e1877cb2f463b72b Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Thu, 29 Oct 2020 21:45:28 +0300 Subject: [PATCH 5/8] Check variable --- src/components/playback/playbackmanager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/playback/playbackmanager.js b/src/components/playback/playbackmanager.js index 7796dafec8..a096d255c1 100644 --- a/src/components/playback/playbackmanager.js +++ b/src/components/playback/playbackmanager.js @@ -2939,7 +2939,7 @@ class PlaybackManager { state.NextMediaType = nextMediaType; - if (isServerItem(streamInfo.item)) { + if (streamInfo && isServerItem(streamInfo.item)) { if (player.supportsProgress === false && state.PlayState && !state.PlayState.PositionTicks) { state.PlayState.PositionTicks = streamInfo.item.RunTimeTicks; } From f805bef9e51ca1de0e8623bf8bb6ad57d18af6e3 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Thu, 29 Oct 2020 22:08:06 +0300 Subject: [PATCH 6/8] Split then/catch. Remove explicit player destroying --- src/components/playback/playbackmanager.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/components/playback/playbackmanager.js b/src/components/playback/playbackmanager.js index a096d255c1..54831094e1 100644 --- a/src/components/playback/playbackmanager.js +++ b/src/components/playback/playbackmanager.js @@ -2240,17 +2240,14 @@ class PlaybackManager { const streamInfo = createStreamInfoFromUrlItem(item); streamInfo.fullscreen = playOptions.fullscreen; getPlayerData(player).isChangingStream = false; - return player.play(streamInfo).then(function () { + return player.play(streamInfo).then(() => { loading.hide(); onPlaybackStartedFn(); onPlaybackStarted(player, playOptions, streamInfo); - }, function () { + }).catch(() => { // TODO: show error message self.stop(player); loading.hide(); - }).catch(() => { - player.destroy(); - loading.hide(); }); }); } From 6aa0d7c31870de4b75bad2cc44d1477de95e85f2 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Thu, 29 Oct 2020 23:52:52 +0300 Subject: [PATCH 7/8] Add error message --- src/components/playback/playbackmanager.js | 4 ++-- src/plugins/youtubePlayer/plugin.js | 10 +++++++++- src/strings/en-us.json | 6 +++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/components/playback/playbackmanager.js b/src/components/playback/playbackmanager.js index 54831094e1..dcb9479674 100644 --- a/src/components/playback/playbackmanager.js +++ b/src/components/playback/playbackmanager.js @@ -2244,10 +2244,10 @@ class PlaybackManager { loading.hide(); onPlaybackStartedFn(); onPlaybackStarted(player, playOptions, streamInfo); - }).catch(() => { - // TODO: show error message + }).catch((errorCode) => { self.stop(player); loading.hide(); + showPlaybackInfoErrorMessage(self, errorCode || ''); }); }); } diff --git a/src/plugins/youtubePlayer/plugin.js b/src/plugins/youtubePlayer/plugin.js index 9079e2bcb6..2976f52e57 100644 --- a/src/plugins/youtubePlayer/plugin.js +++ b/src/plugins/youtubePlayer/plugin.js @@ -5,6 +5,14 @@ import loading from 'loading'; /* globals YT */ +const errorCodes = { + 2: 'YoutubeBadRequest', + 5: 'YoutubePlaybackError', + 100: 'YoutubeNotFound', + 101: 'YoutubeDenied', + 150: 'YoutubeDenied' +}; + function zoomIn(elem, iterations) { const keyframes = [ { transform: 'scale3d(.2, .2, .2) ', opacity: '.6', offset: 0 }, @@ -143,7 +151,7 @@ function setCurrentSrc(instance, elem, options) { events.trigger(instance, 'pause'); } }, - 'onError': () => reject() + 'onError': (e) => reject(errorCodes[e.data] || '') // FIXME: default error code/text? }, playerVars: { controls: 0, diff --git a/src/strings/en-us.json b/src/strings/en-us.json index ab547f3854..a5a2279bdd 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -1421,5 +1421,9 @@ "SubtitleVerticalPositionHelp": "Line number where text appears. Positive numbers indicate top down. Negative numbers indicate bottom up.", "Preview": "Preview", "LabelMaxMuxingQueueSize": "Max muxing queue size:", - "LabelMaxMuxingQueueSizeHelp": "Maximum number of packets that can be buffered while waiting for all streams to initialize. Try to increase it if you still encounter \"Too many packets buffered for output stream\" error in ffmpeg logs. The recommended value is 2048." + "LabelMaxMuxingQueueSizeHelp": "Maximum number of packets that can be buffered while waiting for all streams to initialize. Try to increase it if you still encounter \"Too many packets buffered for output stream\" error in ffmpeg logs. The recommended value is 2048.", + "YoutubeBadRequest": "Bad request.", + "YoutubePlaybackError": "Requested video cannot be played.", + "YoutubeNotFound": "Video not found.", + "YoutubeDenied": "Requested video is not allowed to be played in embedded players." } From 89e2e77886c9d6d49c5f9bbbb27e9ce603e37002 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Sat, 21 Nov 2020 22:51:24 +0300 Subject: [PATCH 8/8] Add default error text --- src/components/playback/playbackmanager.js | 2 +- src/plugins/youtubePlayer/plugin.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/playback/playbackmanager.js b/src/components/playback/playbackmanager.js index e62e045325..a2e07fe8fa 100644 --- a/src/components/playback/playbackmanager.js +++ b/src/components/playback/playbackmanager.js @@ -2247,7 +2247,7 @@ class PlaybackManager { }).catch((errorCode) => { self.stop(player); loading.hide(); - showPlaybackInfoErrorMessage(self, errorCode || ''); + showPlaybackInfoErrorMessage(self, errorCode || 'ErrorDefault'); }); }); } diff --git a/src/plugins/youtubePlayer/plugin.js b/src/plugins/youtubePlayer/plugin.js index eea54c729e..93bb435c27 100644 --- a/src/plugins/youtubePlayer/plugin.js +++ b/src/plugins/youtubePlayer/plugin.js @@ -148,7 +148,7 @@ function setCurrentSrc(instance, elem, options) { Events.trigger(instance, 'pause'); } }, - 'onError': (e) => reject(errorCodes[e.data] || '') // FIXME: default error code/text? + 'onError': (e) => reject(errorCodes[e.data] || 'ErrorDefault') }, playerVars: { controls: 0,