Skip to content

Commit

Permalink
fix keystatuschange listener
Browse files Browse the repository at this point in the history
  • Loading branch information
adrums86 committed Dec 11, 2023
1 parent 2904088 commit be0d95e
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/videojs-http-streaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ const removeOnResponseHook = (xhr, callback) => {
}
};

const debounce = (callback, timeout = 10) => {
const debounce = (callback, timeout = 1000) => {
let timeoutId;

return (...args) => {
Expand Down Expand Up @@ -1139,19 +1139,12 @@ class VhsHandler extends Component {

this.player_.tech_.on('keystatuschange', (e) => {
if (e.status !== 'output-restricted') {
const shouldDisableNonUsablePlaylists = this.options_.disableNonUsablePlaylists &&
this.playlistController_.mainPlaylistLoader_.addKeyStatus &&
this.playlistController_.mainPlaylistLoader_.excludeNonUsablePlaylists;

if (!shouldDisableNonUsablePlaylists) {
return;
}
const debounceExcludeAndChange = debounce(() => {
this.playlistController_.mainPlaylistLoader_.excludeNonUsablePlaylists();
this.playlistController_.excludeNonUsablePlaylistsByKID();
this.playlistController_.fastQualityChange_();

Check warning on line 1144 in src/videojs-http-streaming.js

View check run for this annotation

Codecov / codecov/patch

src/videojs-http-streaming.js#L1143-L1144

Added lines #L1143 - L1144 were not covered by tests
});

this.playlistController_.mainPlaylistLoader_.addKeyStatus(e.keyId, e.status);
this.playlistController_.addKeyStatus(e.keyId, e.status);
// This is called in a loop for each keystatuseschange event from the MediaKeySession
// so we need to debounce this so we don't repeatedly filter the playlists.
debounceExcludeAndChange();
Expand Down

0 comments on commit be0d95e

Please sign in to comment.