bigscreen-player 8.10.2 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/{imscsubtitles-2963ed4a.js → imscsubtitles-72c8e371.js} +28 -21
- package/dist/esm/{legacysubtitles-ff50db6c.js → legacysubtitles-e745299b.js} +12 -10
- package/dist/esm/{main-e65c195f.js → main-5b4d5af8.js} +1336 -1567
- package/dist/esm/main.d.ts +108 -79
- package/dist/esm/main.js +2 -1
- package/dist/esm/{msestrategy-d01d2a86.js → msestrategy-31c89861.js} +209 -239
- package/package.json +1 -1
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { fromXML, generateISD, renderHTML } from 'smp-imsc';
|
|
2
|
-
import { f as findSegmentTemplate, L as LoadUrl, a as
|
|
2
|
+
import { f as findSegmentTemplate, L as LoadUrl, a as DebugTool, P as Plugins, U as Utils, D as DOMHelpers } from './main-5b4d5af8.js';
|
|
3
|
+
import 'tslib';
|
|
3
4
|
|
|
4
5
|
const SEGMENTS_BUFFER_SIZE = 3;
|
|
5
6
|
const LOAD_ERROR_COUNT_MAX = 3;
|
|
6
7
|
|
|
7
8
|
function IMSCSubtitles(mediaPlayer, autoStart, parentElement, mediaSources, defaultStyleOpts) {
|
|
8
|
-
const windowStartEpochSeconds = mediaSources?.time().windowStartTime / 1000;
|
|
9
|
-
const presentationTimeOffsetSeconds = mediaSources?.time().presentationTimeOffsetSeconds;
|
|
10
|
-
|
|
11
9
|
let imscRenderOpts = transformStyleOptions(defaultStyleOpts);
|
|
12
10
|
let currentSegmentRendered = {};
|
|
13
11
|
let loadErrorCount = 0;
|
|
@@ -21,8 +19,14 @@ function IMSCSubtitles(mediaPlayer, autoStart, parentElement, mediaSources, defa
|
|
|
21
19
|
start();
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
function
|
|
25
|
-
|
|
22
|
+
function hasOffset() {
|
|
23
|
+
const { presentationTimeOffsetInMilliseconds } = mediaSources.time();
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
typeof presentationTimeOffsetInMilliseconds === "number" &&
|
|
27
|
+
isFinite(presentationTimeOffsetInMilliseconds) &&
|
|
28
|
+
presentationTimeOffsetInMilliseconds > 0
|
|
29
|
+
)
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
function calculateSegmentNumber() {
|
|
@@ -31,7 +35,7 @@ function IMSCSubtitles(mediaPlayer, autoStart, parentElement, mediaSources, defa
|
|
|
31
35
|
// Add 1 as the PTO gives segment '0' relative to the presentation time.
|
|
32
36
|
// DASH segments use one-based indexing, so add 1 to the result of PTO.
|
|
33
37
|
// (Imagine PTO was 0)
|
|
34
|
-
if (
|
|
38
|
+
if (hasOffset()) {
|
|
35
39
|
return segmentNumber + 1
|
|
36
40
|
}
|
|
37
41
|
|
|
@@ -71,7 +75,7 @@ function IMSCSubtitles(mediaPlayer, autoStart, parentElement, mediaSources, defa
|
|
|
71
75
|
onLoad: (responseXML, responseText) => {
|
|
72
76
|
resetLoadErrorCount();
|
|
73
77
|
if (!responseXML && isSubtitlesWhole()) {
|
|
74
|
-
|
|
78
|
+
DebugTool.error("responseXML is invalid");
|
|
75
79
|
Plugins.interface.onSubtitlesXMLError({ cdn: mediaSources.currentSubtitlesCdn() });
|
|
76
80
|
stop();
|
|
77
81
|
return
|
|
@@ -85,7 +89,7 @@ function IMSCSubtitles(mediaPlayer, autoStart, parentElement, mediaSources, defa
|
|
|
85
89
|
: responseText.split(/<\?xml[^?]+\?>/i)[1] || responseText;
|
|
86
90
|
|
|
87
91
|
if (isSubtitlesWhole()) {
|
|
88
|
-
|
|
92
|
+
DebugTool.info(`XML trim duration: ${Date.now() - preTrimTime}`);
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
const preParseTime = Date.now();
|
|
@@ -93,7 +97,7 @@ function IMSCSubtitles(mediaPlayer, autoStart, parentElement, mediaSources, defa
|
|
|
93
97
|
const xml = fromXML(xmlText);
|
|
94
98
|
|
|
95
99
|
if (isSubtitlesWhole()) {
|
|
96
|
-
|
|
100
|
+
DebugTool.info(`XML parse duration: ${Date.now() - preParseTime}`);
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
const times = xml.getMediaTimeEvents();
|
|
@@ -110,18 +114,18 @@ function IMSCSubtitles(mediaPlayer, autoStart, parentElement, mediaSources, defa
|
|
|
110
114
|
}
|
|
111
115
|
} catch (error) {
|
|
112
116
|
error.name = "SubtitlesTransformError";
|
|
113
|
-
|
|
117
|
+
DebugTool.error(error);
|
|
114
118
|
|
|
115
119
|
Plugins.interface.onSubtitlesTransformError();
|
|
116
120
|
stop();
|
|
117
121
|
}
|
|
118
122
|
},
|
|
119
123
|
onError: ({ statusCode, ...rest } = {}) => {
|
|
120
|
-
|
|
124
|
+
DebugTool.error(`Failed to load subtitle data. Status code: ${statusCode}`);
|
|
121
125
|
loadErrorFailover({ statusCode, ...rest });
|
|
122
126
|
},
|
|
123
127
|
onTimeout: () => {
|
|
124
|
-
|
|
128
|
+
DebugTool.error("Loading subtitles timed out");
|
|
125
129
|
Plugins.interface.onSubtitlesTimeout({ cdn: mediaSources.currentSubtitlesCdn() });
|
|
126
130
|
stop();
|
|
127
131
|
},
|
|
@@ -141,16 +145,15 @@ function IMSCSubtitles(mediaPlayer, autoStart, parentElement, mediaSources, defa
|
|
|
141
145
|
}
|
|
142
146
|
|
|
143
147
|
function loadErrorFailover(opts) {
|
|
144
|
-
const errorCase = () => {
|
|
145
|
-
DebugToolInstance.info("No more CDNs available for subtitle failover");
|
|
146
|
-
};
|
|
147
|
-
|
|
148
148
|
const isWhole = isSubtitlesWhole();
|
|
149
149
|
|
|
150
150
|
if (isWhole || (!isWhole && loadErrorLimit())) {
|
|
151
151
|
stop();
|
|
152
152
|
segments = [];
|
|
153
|
-
mediaSources
|
|
153
|
+
mediaSources
|
|
154
|
+
.failoverSubtitles(opts)
|
|
155
|
+
.then(() => start())
|
|
156
|
+
.catch(() => DebugTool.info("No more CDNs available for subtitle failover"));
|
|
154
157
|
}
|
|
155
158
|
}
|
|
156
159
|
|
|
@@ -284,7 +287,7 @@ function IMSCSubtitles(mediaPlayer, autoStart, parentElement, mediaSources, defa
|
|
|
284
287
|
renderHTML(isd, subsElement, null, renderHeight, renderWidth, false, null, null, false, styleOpts);
|
|
285
288
|
} catch (error) {
|
|
286
289
|
error.name = "SubtitlesRenderError";
|
|
287
|
-
|
|
290
|
+
DebugTool.error(error);
|
|
288
291
|
|
|
289
292
|
Plugins.interface.onSubtitlesRenderError();
|
|
290
293
|
}
|
|
@@ -309,11 +312,15 @@ function IMSCSubtitles(mediaPlayer, autoStart, parentElement, mediaSources, defa
|
|
|
309
312
|
}
|
|
310
313
|
|
|
311
314
|
function isValidTime(time) {
|
|
312
|
-
return time >=
|
|
315
|
+
return time >= 0
|
|
313
316
|
}
|
|
314
317
|
|
|
315
318
|
function getCurrentTime() {
|
|
316
|
-
|
|
319
|
+
const presentationTimeInSeconds = mediaPlayer.getCurrentTime();
|
|
320
|
+
|
|
321
|
+
return hasOffset()
|
|
322
|
+
? presentationTimeInSeconds + mediaSources.time().presentationTimeOffsetInMilliseconds / 1000
|
|
323
|
+
: presentationTimeInSeconds
|
|
317
324
|
}
|
|
318
325
|
|
|
319
326
|
function start() {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { D as DOMHelpers, a as
|
|
1
|
+
import { D as DOMHelpers, a as DebugTool, P as Plugins, L as LoadUrl, T as TransportControlPosition } from './main-5b4d5af8.js';
|
|
2
|
+
import 'tslib';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Safely checks if an attribute exists on an element.
|
|
@@ -246,7 +247,7 @@ function Transformer() {
|
|
|
246
247
|
subtitlesForTime: (time) => items.filter((subtitle) => subtitle.start < time && subtitle.end > time),
|
|
247
248
|
}
|
|
248
249
|
} catch (e) {
|
|
249
|
-
|
|
250
|
+
DebugTool.info("Error transforming captions : " + e);
|
|
250
251
|
Plugins.interface.onSubtitlesTransformError();
|
|
251
252
|
}
|
|
252
253
|
}
|
|
@@ -304,7 +305,7 @@ function Renderer(id, captionsXML, mediaPlayer) {
|
|
|
304
305
|
|
|
305
306
|
confirmCaptionsRendered();
|
|
306
307
|
} catch (e) {
|
|
307
|
-
|
|
308
|
+
DebugTool.info("Exception while rendering subtitles: " + e);
|
|
308
309
|
Plugins.interface.onSubtitlesRenderError();
|
|
309
310
|
}
|
|
310
311
|
}
|
|
@@ -364,19 +365,20 @@ function LegacySubtitles(mediaPlayer, autoStart, parentElement, mediaSources) {
|
|
|
364
365
|
if (responseXML) {
|
|
365
366
|
createContainer(responseXML);
|
|
366
367
|
} else {
|
|
367
|
-
|
|
368
|
+
DebugTool.info("Error: responseXML is invalid.");
|
|
368
369
|
Plugins.interface.onSubtitlesXMLError({ cdn: mediaSources.currentSubtitlesCdn() });
|
|
369
370
|
}
|
|
370
371
|
},
|
|
371
372
|
onError: ({ statusCode, ...rest } = {}) => {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
373
|
+
DebugTool.info(`Error loading subtitles data: ${statusCode}`);
|
|
374
|
+
|
|
375
|
+
mediaSources
|
|
376
|
+
.failoverSubtitles({ statusCode, ...rest })
|
|
377
|
+
.then(() => loadSubtitles())
|
|
378
|
+
.catch(() => DebugTool.info("Failed to load from subtitles file from all available CDNs"));
|
|
377
379
|
},
|
|
378
380
|
onTimeout: () => {
|
|
379
|
-
|
|
381
|
+
DebugTool.info("Request timeout loading subtitles");
|
|
380
382
|
Plugins.interface.onSubtitlesTimeout({ cdn: mediaSources.currentSubtitlesCdn() });
|
|
381
383
|
},
|
|
382
384
|
});
|