Skip to content

Commit

Permalink
fix(AirPlay): Don't show subtitles on the player when using AirPlay (s…
Browse files Browse the repository at this point in the history
…haka-project#7514)

This only happens when using src= mode
  • Loading branch information
avelad authored Oct 29, 2024
1 parent 6d0ee51 commit 7c6dac5
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2949,22 +2949,36 @@ shaka.Player = class extends shaka.util.FakeEventTarget {

if (mediaElement.textTracks) {
this.createTextDisplayer_();
this.loadEventManager_.listen(
mediaElement, 'enterpictureinpicture', () => {
const track = this.getFilteredTextTracks_()
.find((t) => t.mode !== 'disabled');
if (track) {
track.mode = 'showing';
}
});
this.loadEventManager_.listen(
mediaElement, 'leavepictureinpicture', () => {
const track = this.getFilteredTextTracks_()
.find((t) => t.mode !== 'disabled');
if (track) {
track.mode = 'hidden';
}
});
const setShowingMode = () => {
const track = this.getFilteredTextTracks_()
.find((t) => t.mode !== 'disabled');
if (track) {
track.mode = 'showing';
}
};
const setHiddenMode = () => {
const track = this.getFilteredTextTracks_()
.find((t) => t.mode !== 'disabled');
if (track) {
track.mode = 'hidden';
}
};
this.loadEventManager_.listen(mediaElement, 'enterpictureinpicture',
() => setShowingMode());
this.loadEventManager_.listen(mediaElement, 'leavepictureinpicture',
() => setHiddenMode());
if (mediaElement.remote) {
this.loadEventManager_.listen(mediaElement.remote, 'connect',
() => setHiddenMode());
this.loadEventManager_.listen(mediaElement.remote, 'connecting',
() => setHiddenMode());
this.loadEventManager_.listen(mediaElement.remote, 'disconnect',
() => setHiddenMode());
} else if ('webkitCurrentPlaybackTargetIsWireless' in mediaElement) {
this.loadEventManager_.listen(mediaElement,
'webkitcurrentplaybacktargetiswirelesschanged',
() => setHiddenMode());
}
}
// Add all media element listeners.
this.addBasicMediaListeners_(mediaElement, startTimeOfLoad);
Expand Down

0 comments on commit 7c6dac5

Please sign in to comment.