Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Prefer SimpleTextDisplayer on iOS #7569

Merged
merged 5 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -6512,7 +6512,10 @@ 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 devices where the Fullscreen API is not available we prefer
// SimpleTextDisplayer because it works with the Fullscreen API of the
// video element itself.
if (this.videoContainer_ && document.fullscreenEnabled) {
joeyparrish marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a little more subtle. If you had a device without a fullscreen API of any kind, we would still want UITextDisplayer. The issue is that we end up on the WebKit-specific video-only fullscreen method, which breaks UITextDisplayer.

I think what we really want is something like this.videoContainer_ && (shouldUseDocumentFullscreen(this.config_) || !isFullScreenSupported()), where shouldUseDocumentFullscreen and isFullScreenSupported are extracted from ui/controls.js and made static.

Is this too subtle/complex?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I’ll do it tomorrow!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this only happens on iOS, I think I'll make a simpler version

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) {
joeyparrish marked this conversation as resolved.
Show resolved Hide resolved
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
Loading