From b5da41ed80b96e8edae970c39dd5fac7348a9a55 Mon Sep 17 00:00:00 2001 From: Agajan J Date: Mon, 11 Jul 2022 13:53:11 -0700 Subject: [PATCH] fix: VTT Cue Parsing On PlayStation 4 (#4340) Need to exclude PlayStation 4 from TextDecoder usage, because even if TextDecoder is defined, VTT cues are not properly parsed on that platform. Closes #4321 --- CONTRIBUTORS | 1 + lib/util/string_utils.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 846e3bcfc..a11413fd7 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -24,6 +24,7 @@ Aaron Vaage Adrián Gómez Llorente +Agajan Jumakuliyev Aidan Ridley Alex Jones Alvaro Velad Galvan diff --git a/lib/util/string_utils.js b/lib/util/string_utils.js index 61ad403c6..1fe17e6d5 100644 --- a/lib/util/string_utils.js +++ b/lib/util/string_utils.js @@ -11,6 +11,7 @@ goog.require('shaka.log'); goog.require('shaka.util.BufferUtils'); goog.require('shaka.util.Error'); goog.require('shaka.util.Lazy'); +goog.require('shaka.util.Platform'); /** @@ -36,7 +37,7 @@ shaka.util.StringUtils = class { if (uint8[0] == 0xef && uint8[1] == 0xbb && uint8[2] == 0xbf) { uint8 = uint8.subarray(3); } - if (window.TextDecoder) { + if (window.TextDecoder && !shaka.util.Platform.isPS4()) { // Use the TextDecoder interface to decode the text. This has the // advantage compared to the previously-standard decodeUriComponent that // it will continue parsing even if it finds an invalid UTF8 character, @@ -160,7 +161,7 @@ shaka.util.StringUtils = class { * @export */ static toUTF8(str) { - if (window.TextEncoder) { + if (window.TextEncoder && !shaka.util.Platform.isPS4()) { const utf8Encoder = new TextEncoder(); return shaka.util.BufferUtils.toArrayBuffer(utf8Encoder.encode(str)); } else {