Skip to content

Commit

Permalink
Handle AirPlay key events properly
Browse files Browse the repository at this point in the history
  • Loading branch information
cfra committed Nov 11, 2022
1 parent c8ca31a commit 40a2b73
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,21 @@ const onPlayerReady = (player, emeError) => {

setupSessions(player);

/*
* If playback is switched to AirPlay, we will receive another encrypted event,
* proxied from the AirPlay device, as is described here:
*
* https://developer.apple.com/streaming/fps/FairPlayStreamingOverview.pdf
*
* To accomodate for this, we should clear our list of sessions when the playback
* target changes, because the request is otherwise dropped as a duplicate.
*/
if ('webkitCurrentPlaybackTargetIsWireless' in player.tech_.el_) {
player.tech_.el_.addEventListener('webkitcurrentplaybacktargetiswirelesschanged', () => {
player.eme.sessions = [];
});
}

if (window.MediaKeys) {
// Support EME 05 July 2016
// Chrome 42+, Firefox 47+, Edge, Safari 12.1+ on macOS 10.14+
Expand Down

0 comments on commit 40a2b73

Please sign in to comment.