From 455163f874f623f6ffd4edc85cf81966f27aa26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Thu, 30 Jan 2025 18:10:18 +0100 Subject: [PATCH] feat: Add new error code when the streaming is not allowed (#7994) Maybe related to https://github.com/shaka-project/shaka-player/issues/7960 --- lib/media/media_source_engine.js | 6 ++++++ lib/media/streaming_engine.js | 4 ++++ lib/util/error.js | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/lib/media/media_source_engine.js b/lib/media/media_source_engine.js index f5a9799736..a4315f9eeb 100644 --- a/lib/media/media_source_engine.js +++ b/lib/media/media_source_engine.js @@ -2066,6 +2066,12 @@ shaka.media.MediaSourceEngine = class { shaka.util.Error.Category.MEDIA, shaka.util.Error.Code.QUOTA_EXCEEDED_ERROR, contentType)); + } else if (!this.isStreamingAllowed()) { + next.p.reject(new shaka.util.Error( + shaka.util.Error.Severity.CRITICAL, + shaka.util.Error.Category.MEDIA, + shaka.util.Error.Code.STREAMING_NOT_ALLOWED, + contentType)); } else { next.p.reject(new shaka.util.Error( shaka.util.Error.Severity.CRITICAL, diff --git a/lib/media/streaming_engine.js b/lib/media/streaming_engine.js index 12c7e283c3..c09d9396a9 100644 --- a/lib/media/streaming_engine.js +++ b/lib/media/streaming_engine.js @@ -1858,6 +1858,10 @@ shaka.media.StreamingEngine = class { mediaState.performingUpdate = false; this.cancelUpdate_(mediaState); this.scheduleUpdate_(mediaState, 0); + } else if (error.code == shaka.util.Error.Code.STREAMING_NOT_ALLOWED) { + mediaState.performingUpdate = false; + this.cancelUpdate_(mediaState); + this.scheduleUpdate_(mediaState, 0); } else if (mediaState.type == ContentType.TEXT && this.config_.ignoreTextStreamFailures) { if (error.code == shaka.util.Error.Code.BAD_HTTP_STATUS) { diff --git a/lib/util/error.js b/lib/util/error.js index d130969e85..90a3bc07b4 100644 --- a/lib/util/error.js +++ b/lib/util/error.js @@ -521,6 +521,13 @@ shaka.util.Error.Code = { */ 'TRANSMUXING_NO_VIDEO_DATA': 3023, + /** + * A MediaSource operation is not allowed because the streaming is not + * allowed. + *
error.data[0] is the type of content which caused the error. + */ + 'STREAMING_NOT_ALLOWED': 3024, + /** * The Player was unable to guess the manifest type based on file extension