Skip to content

Commit

Permalink
fix(text track display): update on playerresize and orientationchange (
Browse files Browse the repository at this point in the history
…#5447)

On mobile devices, when changing orientation, or if the player gets resized, the captions won't update to reflect the new orientation or player size. However, they do get updated the next time they are redrawn. Instead, we should redraw the captions whenever `orientationchange` and `playerresize` get triggered.
  • Loading branch information
gkatsev committed Oct 31, 2018
1 parent 404afb7 commit ae23f1e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/js/tracks/text-track-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ class TextTrackDisplay extends Component {
constructor(player, options, ready) {
super(player, options, ready);

const updateDisplayHandler = Fn.bind(this, this.updateDisplay);

player.on('loadstart', Fn.bind(this, this.toggleDisplay));
player.on('texttrackchange', Fn.bind(this, this.updateDisplay));
player.on('texttrackchange', updateDisplayHandler);
player.on('loadstart', Fn.bind(this, this.preselectTrack));

// This used to be called during player init, but was causing an error
Expand All @@ -112,7 +114,11 @@ class TextTrackDisplay extends Component {
return;
}

player.on('fullscreenchange', Fn.bind(this, this.updateDisplay));
player.on('fullscreenchange', updateDisplayHandler);
player.on('playerresize', updateDisplayHandler);

window.addEventListener('orientationchange', updateDisplayHandler);
player.on('dispose', () => window.removeEventListener('orientationchange', updateDisplayHandler));

const tracks = this.options_.playerOptions.tracks || [];

Expand Down

0 comments on commit ae23f1e

Please sign in to comment.