Skip to content

Commit

Permalink
fix: Prefer SimpleTextDisplayer on iOS (#7569)
Browse files Browse the repository at this point in the history
Fixes #7568
  • Loading branch information
avelad committed Nov 15, 2024
1 parent b8bc8f4 commit aec3d83
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -6513,7 +6513,12 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
// Because this.video_ may not be set when the config is built, the default
// TextDisplay factory must capture a reference to "this".
config.textDisplayFactory = () => {
if (this.videoContainer_) {
// On iOS where the Fullscreen API is not available we prefer
// SimpleTextDisplayer because it works with the Fullscreen API of the
// video element itself.
const Platform = shaka.util.Platform;
if (this.videoContainer_ &&
(!Platform.safariVersion() || document.fullscreenEnabled)) {
const latestConfig = this.getConfiguration();
return new shaka.text.UITextDisplayer(
this.video_, this.videoContainer_, latestConfig.textDisplayer);
Expand Down
7 changes: 7 additions & 0 deletions lib/text/ui_text_displayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ goog.provide('shaka.text.UITextDisplayer');

goog.require('goog.asserts');
goog.require('shaka.Deprecate');
goog.require('shaka.log');
goog.require('shaka.text.Cue');
goog.require('shaka.text.CueRegion');
goog.require('shaka.text.Utils');
Expand All @@ -35,6 +36,12 @@ shaka.text.UITextDisplayer = class {
constructor(video, videoContainer, config) {
goog.asserts.assert(videoContainer, 'videoContainer should be valid.');

if (!document.fullscreenEnabled) {
shaka.log.alwaysWarn('Using UITextDisplayer in a browser without ' +
'Fullscreen API support causes subtitles to not be rendered in ' +
'fullscreen');
}

/** @private {boolean} */
this.isTextVisible_ = false;

Expand Down

0 comments on commit aec3d83

Please sign in to comment.