Skip to content

Commit

Permalink
fix: VTT Cue Parsing On PlayStation 4 (#4340)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
agajassi authored Jul 11, 2022
1 parent 5b18069 commit b5da41e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

Aaron Vaage <[email protected]>
Adrián Gómez Llorente <[email protected]>
Agajan Jumakuliyev <[email protected]>
Aidan Ridley <[email protected]>
Alex Jones <[email protected]>
Alvaro Velad Galvan <[email protected]>
Expand Down
5 changes: 3 additions & 2 deletions lib/util/string_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');


/**
Expand All @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit b5da41e

Please sign in to comment.