Skip to content

Commit

Permalink
Ignore shaka error SRC_EQUALS_PRELOAD_NOT_SUPPORTED as that is handle…
Browse files Browse the repository at this point in the history
…d. Remove preloadManager required for skipToPreloadedMediaProduct so that non-preloadable content also play. (#209)
  • Loading branch information
enjikaka authored Oct 2, 2024
1 parent a225fd0 commit da61852
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/player/src/player/shakaPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,8 @@ export default class ShakaPlayer extends BasePlayer {
const errorCode = `S${error.code}` as ErrorCodes;

switch (error.code) {
case shaka.util.Error.Code.SRC_EQUALS_PRELOAD_NOT_SUPPORTED:
return; // Ignore this error, handled via promise rejection.
case shaka.util.Error.Code.LICENSE_REQUEST_FAILED: // 6007
if (this.currentStreamingSessionId) {
StreamingMetrics.commit({
Expand Down Expand Up @@ -880,6 +882,10 @@ export default class ShakaPlayer extends BasePlayer {
return;
}

this.#preloadManager = await this.shakaInstance.preload(
payload.streamInfo.streamUrl,
);

/*
A play action can only start playback if playback state is not IDLE.
If shaka is currently not playing anything and we preload to play something soon,
Expand All @@ -891,10 +897,6 @@ export default class ShakaPlayer extends BasePlayer {

this.preloadedStreamingSessionId = payload.streamInfo.streamingSessionId;

this.#preloadManager = await this.shakaInstance.preload(
payload.streamInfo.streamUrl,
);

// If we could parse duration from manifest, we can save the media product transition
// and support "touch n go" playback. (re-using a preloaded item for a load)
if (payload.streamInfo.duration) {
Expand Down Expand Up @@ -1062,7 +1064,7 @@ export default class ShakaPlayer extends BasePlayer {
this.preloadedStreamingSessionId,
);

if (this.#preloadedPayload && this.#preloadManager) {
if (this.#preloadedPayload) {
const { mediaProduct, playbackInfo, streamInfo } = this.#preloadedPayload;

return this.#loadAndDispatchMediaProductTransition({
Expand Down

0 comments on commit da61852

Please sign in to comment.