Skip to content

Commit

Permalink
fix(preload): Fix timing of call to stopQueuingLatePhaseQueuedOperati…
Browse files Browse the repository at this point in the history
…ons (#6238)

This method should be called after the load is successful, not if the
load fails.
This also adds a new test that ensures that onKeyStatus_ messages work
correctly, as a regression test.
This was exposed by the test failures, but was not the cause of them.

Issue #6225
  • Loading branch information
theodab authored Feb 12, 2024
1 parent 93d616e commit fd57e7f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1557,13 +1557,13 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
await this.loadInner_(
startTimeOfLoad, prefetchedVariant, segmentPrefetchById);
}, 'loadInner_');
preloadManager.stopQueuingLatePhaseQueuedOperations();
}
this.dispatchEvent(shaka.Player.makeEvent_(
shaka.util.FakeEvent.EventName.Loaded));
} catch (error) {
if (error.code != shaka.util.Error.Code.LOAD_INTERRUPTED) {
await this.unload(/* initializeMediaSource= */ false);
preloadManager.stopQueuingLatePhaseQueuedOperations();
}
throw error;
} finally {
Expand Down
16 changes: 16 additions & 0 deletions test/player_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,22 @@ describe('Player', () => {
expect(player.getLoadMode()).toBe(shaka.Player.LoadMode.MEDIA_SOURCE);
});
});

it('fires keystatuschanged events', async () => {
const keyStatusChanged = jasmine.createSpy('keyStatusChanged');
player.addEventListener(
'keystatuschanged', Util.spyFunc(keyStatusChanged));
player.createDrmEngine = (playerInterface) => {
// Call the onKeyStatus on the playerInterface, before load is finished.
playerInterface.onKeyStatus({
'aaa': 'usable',
'bbb': 'output-restricted',
});
return drmEngine;
};
await player.load(fakeManifestUri, 0, fakeMimeType);
expect(keyStatusChanged).toHaveBeenCalled();
});
}); // describe('load/unload')

describe('getConfiguration', () => {
Expand Down

0 comments on commit fd57e7f

Please sign in to comment.