@eluvio/elv-player-js 2.1.23 → 2.1.25

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.
@@ -160,18 +160,19 @@ export class EluvioPlayer {
160
160
  let options = {
161
161
  ignore_trimming: playoutParameters.ignoreTrimming,
162
162
  resolve: playoutParameters.resolve,
163
- ...(playoutParameters.options || {})
163
+ ...(playoutParameters.options || {}),
164
+ clip_start: (playoutParameters.options || {}).clip_start || playoutParameters.clipStart,
165
+ clip_end: (playoutParameters.options || {}).clip_end || playoutParameters.clipEnd,
164
166
  };
165
167
 
166
- if(playoutParameters.clipStart || playoutParameters.clipEnd) {
167
- options.clip_start = parseFloat(playoutParameters.clipStart || 0);
168
+ let clipStart, clipEnd;
169
+ if(options.clip_start || options.clip_end) {
170
+ clipStart = parseFloat(options.clip_start || 0);
171
+ clipEnd = parseFloat(options.clip_end || 0);
168
172
 
169
- if(playoutParameters.clipEnd) {
170
- options.clip_end = parseFloat(playoutParameters.clipEnd);
171
- }
172
-
173
- options.clip_start = options.clip_start || 0;
174
- options.clip_end = options.clip_end || 9999999;
173
+ // These may need to be adjusted due to content trimming later
174
+ delete options.clip_start;
175
+ delete options.clip_end;
175
176
  }
176
177
 
177
178
  if(!playoutParameters.channel) {
@@ -203,8 +204,6 @@ export class EluvioPlayer {
203
204
 
204
205
  offeringURI = availableOfferings[offeringId].uri;
205
206
 
206
-
207
-
208
207
  if(this.sourceOptions.contentInfo.liveDVR === EluvioPlayerParameters.liveDVR.ON && offeringProperties.dvr_available) {
209
208
  options.dvr = 1;
210
209
  this.dvrAvailable = true;
@@ -215,6 +214,68 @@ export class EluvioPlayer {
215
214
  this.isLive = offeringProperties.live;
216
215
  }
217
216
 
217
+ const GetPlayoutOptions = async options => {
218
+ if(playoutParameters.directLink) {
219
+ return await client.PlayoutOptions({
220
+ offeringURI,
221
+ options
222
+ });
223
+ } else {
224
+ return await client.PlayoutOptions({
225
+ ...playoutParameters,
226
+ handler: playoutParameters.channel ? "channel" : "playout",
227
+ offering: playoutParameters.channel || offeringId,
228
+ options
229
+ });
230
+ }
231
+ };
232
+
233
+ if(!this.sourceOptions.playoutOptions) {
234
+ let playoutOptions;
235
+
236
+ if(!clipStart && !clipEnd) {
237
+ // No clipping
238
+ playoutOptions = await GetPlayoutOptions(options);
239
+ } else if(!playoutParameters.clipRelativeToUntrimmed) {
240
+ // Clip without considering trimming
241
+ playoutOptions = await GetPlayoutOptions({
242
+ ...options,
243
+ clip_start: clipStart,
244
+ clip_end: clipEnd
245
+ });
246
+ } else {
247
+ // Content may be trimmed - get full content to determine start offset and adjust clip points accordingly
248
+ playoutOptions = await GetPlayoutOptions(options);
249
+
250
+ let offset;
251
+ try {
252
+ for(const protocol of Object.keys(playoutOptions || {})) {
253
+ for(const drm of Object.keys(playoutOptions[protocol].playoutMethods || {})) {
254
+ if(typeof (playoutOptions[protocol].playoutMethods[drm].properties || {}).start_offset_float !== "undefined") {
255
+ offset = parseFloat(playoutOptions[protocol].playoutMethods[drm].properties.start_offset_float);
256
+ break;
257
+ }
258
+ }
259
+
260
+ if(typeof offset !== "undefined") {
261
+ break;
262
+ }
263
+ }
264
+ } catch(error) {
265
+ this.Log("Failed to load content offset for clip adjustment:");
266
+ this.Log(error, true);
267
+ }
268
+
269
+ playoutOptions = await GetPlayoutOptions({
270
+ ...options,
271
+ clip_start: (clipStart || 0) - (offset || 0),
272
+ clip_end: ((clipEnd || 0) - (offset || 0)) || 9999999
273
+ });
274
+ }
275
+
276
+ this.sourceOptions.playoutOptions = playoutOptions;
277
+ }
278
+
218
279
  if(playoutParameters.directLink) {
219
280
  if(!this.sourceOptions.playoutOptions) {
220
281
  this.sourceOptions.playoutOptions = await client.PlayoutOptions({
@@ -491,6 +552,7 @@ export class EluvioPlayer {
491
552
  versionHash,
492
553
  offering,
493
554
  compositionKey,
555
+ trimOffset,
494
556
  clipStart,
495
557
  clipEnd
496
558
  };
@@ -577,7 +639,7 @@ export class EluvioPlayer {
577
639
  if(this.thumbnailTrackUrl) {
578
640
  this.thumbnailHandler = new ThumbnailHandler(
579
641
  this.thumbnailTrackUrl,
580
- (this.playerOptions.startTime || this.sourceOptions.playoutParameters.clipStart || 0) - trimOffset
642
+ trimOffset || 0
581
643
  );
582
644
  this.thumbnailHandler.LoadThumbnails()
583
645
  .then(() => {
@@ -164,6 +164,7 @@ export const DefaultParameters = {
164
164
  authorizationToken: undefined,
165
165
  clipStart: undefined,
166
166
  clipEnd: undefined,
167
+ clipRelativeToUntrimmed: true,
167
168
  audioTrackLabel: undefined,
168
169
  options: undefined
169
170
  }
@@ -59,8 +59,8 @@ const FormatVTTCue = ({label, cue, offset=0}) => {
59
59
  tagId,
60
60
  tagType: "vtt",
61
61
  label,
62
- startTime: cue.startTime + offset,
63
- endTime: cue.endTime + offset,
62
+ startTime: cue.startTime - offset,
63
+ endTime: cue.endTime - offset,
64
64
  text: cue.text,
65
65
  tag: cueCopy
66
66
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-player-js",
3
- "version": "2.1.23",
3
+ "version": "2.1.25",
4
4
  "description": "![Eluvio Logo](lib/static/images/Logo.png \"Eluvio Logo\")",
5
5
  "main": "dist/elv-player-js.es.js",
6
6
  "license": "MIT",