Skip to content

Commit 2bff8f1

Browse files
authored
BADGERS-535: publish error when segment download fails on final CDN (#347)
* throw error when init segment/content download on final CDN fails
1 parent dae3934 commit 2bff8f1

File tree

2 files changed

+53
-4
lines changed

2 files changed

+53
-4
lines changed

src/playbackstrategy/msestrategy.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,9 @@ function MSEStrategy(mediaSources, windowType, mediaKind, playbackElement, isUHD
217217

218218
// Don't raise an error on fragment download error
219219
if (
220-
event.error.code === DashJSEvents.DOWNLOAD_CONTENT_ERROR_CODE ||
221-
event.error.code === DashJSEvents.DOWNLOAD_INIT_SEGMENT_ERROR_CODE
220+
(event.error.code === DashJSEvents.DOWNLOAD_CONTENT_ERROR_CODE ||
221+
event.error.code === DashJSEvents.DOWNLOAD_INIT_SEGMENT_ERROR_CODE) &&
222+
mediaSources.availableSources().length > 1
222223
) {
223224
return
224225
}

src/playbackstrategy/msestrategy.test.js

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ describe("Media Source Extensions Playback Strategy", () => {
12411241
expect(Plugins.interface.onErrorHandled).not.toHaveBeenCalledWith()
12421242
})
12431243

1244-
it("should not publish error event on initial segment download error", () => {
1244+
it("should not publish error event on init segment download error if more than one CDN available", () => {
12451245
const mockEvent = {
12461246
error: {
12471247
message: "initial segment download error",
@@ -1261,7 +1261,31 @@ describe("Media Source Extensions Playback Strategy", () => {
12611261
expect(mockErrorCallback).not.toHaveBeenCalled()
12621262
})
12631263

1264-
it("should not publish error event on content download error", () => {
1264+
it("should publish error event on init segment download error if only one CDN available", () => {
1265+
const mockEvent = {
1266+
error: {
1267+
message: "initial segment download error",
1268+
code: 28,
1269+
},
1270+
}
1271+
1272+
setUpMSE()
1273+
1274+
const mockErrorCallback = jest.fn()
1275+
mseStrategy.addErrorCallback(null, mockErrorCallback)
1276+
1277+
mseStrategy.load(null, 0)
1278+
1279+
const noop = () => {}
1280+
mediaSources.failover(noop, noop, { isBufferingTimeoutError: true })
1281+
mediaSources.failover(noop, noop, { isBufferingTimeoutError: true })
1282+
1283+
dashEventCallback(dashjsMediaPlayerEvents.ERROR, mockEvent)
1284+
1285+
expect(mockErrorCallback).toHaveBeenCalled()
1286+
})
1287+
1288+
it("should not publish error event on content download error if more than one CDN available", () => {
12651289
const mockEvent = {
12661290
error: {
12671291
message: "content download error",
@@ -1281,6 +1305,30 @@ describe("Media Source Extensions Playback Strategy", () => {
12811305
expect(mockErrorCallback).not.toHaveBeenCalled()
12821306
})
12831307

1308+
it("should publish error event on content download error if only one CDN available", () => {
1309+
const mockEvent = {
1310+
error: {
1311+
message: "content download error",
1312+
code: 27,
1313+
},
1314+
}
1315+
1316+
setUpMSE()
1317+
1318+
const mockErrorCallback = jest.fn()
1319+
mseStrategy.addErrorCallback(null, mockErrorCallback)
1320+
1321+
mseStrategy.load(null, 0)
1322+
1323+
const noop = () => {}
1324+
mediaSources.failover(noop, noop, { isBufferingTimeoutError: true })
1325+
mediaSources.failover(noop, noop, { isBufferingTimeoutError: true })
1326+
1327+
dashEventCallback(dashjsMediaPlayerEvents.ERROR, mockEvent)
1328+
1329+
expect(mockErrorCallback).toHaveBeenCalled()
1330+
})
1331+
12841332
it("should initiate a failover with correct parameters on manifest download error", () => {
12851333
const mockEvent = {
12861334
error: {

0 commit comments

Comments
 (0)