From ccefdb34a100a45e23fc832d473baff12a3b9ba7 Mon Sep 17 00:00:00 2001 From: PikachuEXE Date: Thu, 3 Aug 2023 21:01:08 +0800 Subject: [PATCH] ! Fix unnecessary error message display in toast when paused before video started playing on load (#3835) Caused by https://github.com/FreeTubeApp/FreeTube/pull/3775 --- .../components/ft-video-player/ft-video-player.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/ft-video-player/ft-video-player.js b/src/renderer/components/ft-video-player/ft-video-player.js index a314f3775..365237a01 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.js +++ b/src/renderer/components/ft-video-player/ft-video-player.js @@ -25,6 +25,13 @@ import { import { getProxyUrl } from '../../helpers/api/invidious' import store from '../../store' +const EXPECTED_PLAY_RELATED_ERROR_MESSAGES = [ + // This is thrown when `play()` called but user already viewing another page + 'The play() request was interrupted by a new load request.', + // This is thrown when `pause()` called before video started playing on load + 'The play() request was interrupted by a call to pause()', +] + // YouTube now throttles if you use the `Range` header for the DASH formats, instead of the range query parameter // videojs-http-streaming calls this hook everytime it makes a request, // so we can use it to convert the Range header into the range query parameter for the streaming URLs @@ -1979,9 +1986,8 @@ export default defineComponent({ } promise .catch(err => { - if (err.message.includes('The play() request was interrupted by a new load request.')) { + if (EXPECTED_PLAY_RELATED_ERROR_MESSAGES.some(msg => err.message.includes(msg))) { // Ignoring expected exception - // This is thrown when `play()` called but user already viewing another page // console.debug('Ignoring expected error') // console.debug(err) return