@gcorevideo/player 2.4.0 → 2.4.2

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/index.js CHANGED
@@ -12218,7 +12218,7 @@ const DASHJS = /*@__PURE__*/getDefaultExportFromCjs$1(dash_all_minExports);
12218
12218
  // license that can be found in the LICENSE file.
12219
12219
  const AUTO$1 = -1;
12220
12220
  const { now: now$2 } = Utils;
12221
- const T$2 = "DashPlayback";
12221
+ const T$2 = 'DashPlayback';
12222
12222
  class DashPlayback extends HTML5Video {
12223
12223
  _levels = null;
12224
12224
  _currentLevel = null;
@@ -12270,8 +12270,8 @@ class DashPlayback extends HTML5Video {
12270
12270
  autoSwitchBitrate: {
12271
12271
  video: id === -1,
12272
12272
  },
12273
- ABRStrategy: 'abrL2A'
12274
- }
12273
+ ABRStrategy: 'abrL2A',
12274
+ },
12275
12275
  },
12276
12276
  };
12277
12277
  assert.ok(this._dash, 'An instance of dashjs MediaPlayer is required to switch levels');
@@ -12292,7 +12292,8 @@ class DashPlayback extends HTML5Video {
12292
12292
  }
12293
12293
  }
12294
12294
  get _startTime() {
12295
- if (this._playbackType === Playback.LIVE && this._playlistType !== 'EVENT') {
12295
+ if (this._playbackType === Playback.LIVE &&
12296
+ this._playlistType !== 'EVENT') {
12296
12297
  return this._extrapolatedStartTime;
12297
12298
  }
12298
12299
  return this._playableRegionStartTime;
@@ -12338,7 +12339,8 @@ class DashPlayback extends HTML5Video {
12338
12339
  // Should be 2 or higher, or 0 to disable. Should only need to be increased above 2 if more than one segment is
12339
12340
  // removed from the start of the playlist at a time. E.g if the playlist is cached for 10 seconds and new chunks are
12340
12341
  // added/removed every 5.
12341
- this._extrapolatedWindowNumSegments = this.options.playback?.extrapolatedWindowNumSegments ?? 2;
12342
+ this._extrapolatedWindowNumSegments =
12343
+ this.options.playback?.extrapolatedWindowNumSegments ?? 2;
12342
12344
  if (this.options.playbackType) {
12343
12345
  this._playbackType = this.options.playbackType;
12344
12346
  }
@@ -12403,7 +12405,8 @@ class DashPlayback extends HTML5Video {
12403
12405
  });
12404
12406
  this._dash.on(DASHJS.MediaPlayer.events.METRIC_ADDED, (e) => {
12405
12407
  // Listen for the first manifest request in order to update player UI
12406
- if (e.metric === 'DVRInfo') { // TODO fix typings
12408
+ if (e.metric === 'DVRInfo') {
12409
+ // TODO fix typings
12407
12410
  assert.ok(this._dash, 'An instance of dashjs MediaPlayer is required to get metrics');
12408
12411
  const dvrInfo = this._dash.getDashMetrics().getCurrentDVRInfo('video');
12409
12412
  if (dvrInfo) {
@@ -12508,7 +12511,7 @@ class DashPlayback extends HTML5Video {
12508
12511
  }
12509
12512
  _updateDvr(status) {
12510
12513
  this.trigger(Events$1.PLAYBACK_DVR, status);
12511
- this.trigger(Events$1.PLAYBACK_STATS_ADD, { 'dvr': status });
12514
+ this.trigger(Events$1.PLAYBACK_STATS_ADD, { dvr: status });
12512
12515
  }
12513
12516
  _updateSettings() {
12514
12517
  if (this._playbackType === Playback.VOD) {
@@ -12539,19 +12542,19 @@ class DashPlayback extends HTML5Video {
12539
12542
  Log.error('The media cannot be played because it requires a feature ' +
12540
12543
  'that your browser does not support.');
12541
12544
  }
12542
- else if (event.error === 'manifestError' && (
12543
- // Manifest type not supported
12544
- (event.event.id === 'createParser') ||
12545
- // Codec(s) not supported
12546
- (event.event.id === 'codec') ||
12547
- // No streams available to stream
12548
- (event.event.id === 'nostreams') ||
12549
- // Error creating Stream object
12550
- (event.event.id === 'nostreamscomposed') ||
12551
- // syntax error parsing the manifest
12552
- (event.event.id === 'parse') ||
12553
- // a stream has multiplexed audio+video
12554
- (event.event.id === 'multiplexedrep'))) {
12545
+ else if (event.error === 'manifestError' &&
12546
+ // Manifest type not supported
12547
+ (event.event.id === 'createParser' ||
12548
+ // Codec(s) not supported
12549
+ event.event.id === 'codec' ||
12550
+ // No streams available to stream
12551
+ event.event.id === 'nostreams' ||
12552
+ // Error creating Stream object
12553
+ event.event.id === 'nostreamscomposed' ||
12554
+ // syntax error parsing the manifest
12555
+ event.event.id === 'parse' ||
12556
+ // a stream has multiplexed audio+video
12557
+ event.event.id === 'multiplexedrep')) {
12555
12558
  // These errors have useful error messages, so we forward it on
12556
12559
  const formattedError = this.createError(event.error);
12557
12560
  this.trigger(Events$1.PLAYBACK_ERROR, formattedError);
@@ -12570,7 +12573,8 @@ class DashPlayback extends HTML5Video {
12570
12573
  this.trigger(Events$1.PLAYBACK_ERROR, formattedError);
12571
12574
  Log.error(event.event);
12572
12575
  }
12573
- else if (event.error === 'capability' && event.event === 'encryptedmedia') {
12576
+ else if (event.error === 'capability' &&
12577
+ event.event === 'encryptedmedia') {
12574
12578
  // Browser doesn't support EME
12575
12579
  const formattedError = this.createError(event.error);
12576
12580
  this.trigger(Events$1.PLAYBACK_ERROR, formattedError);
@@ -12598,7 +12602,7 @@ class DashPlayback extends HTML5Video {
12598
12602
  }
12599
12603
  else {
12600
12604
  // ignore the error
12601
- if (typeof event.error === "object") {
12605
+ if (typeof event.error === 'object') {
12602
12606
  const formattedError = this.createError(event.error);
12603
12607
  this.trigger(Events$1.PLAYBACK_ERROR, formattedError);
12604
12608
  Log.error(event.error.message);
@@ -12622,10 +12626,11 @@ class DashPlayback extends HTML5Video {
12622
12626
  const update = {
12623
12627
  current: this.getCurrentTime(),
12624
12628
  total: this.getDuration(),
12625
- firstFragDateTime: this.getProgramDateTime()
12629
+ firstFragDateTime: this.getProgramDateTime(),
12626
12630
  };
12627
- const isSame = this._lastTimeUpdate && (update.current === this._lastTimeUpdate.current &&
12628
- update.total === this._lastTimeUpdate.total);
12631
+ const isSame = this._lastTimeUpdate &&
12632
+ update.current === this._lastTimeUpdate.current &&
12633
+ update.total === this._lastTimeUpdate.total;
12629
12634
  if (isSame) {
12630
12635
  return;
12631
12636
  }
@@ -12642,7 +12647,8 @@ class DashPlayback extends HTML5Video {
12642
12647
  }
12643
12648
  get dvrEnabled() {
12644
12649
  assert.ok(this._dash, 'An instance of dashjs MediaPlayer is required to get the DVR status');
12645
- return this._dash?.getDVRWindowSize() >= this._minDvrSize && this.getPlaybackType() === Playback.LIVE;
12650
+ return (this._dash?.getDVRWindowSize() >= this._minDvrSize &&
12651
+ this.getPlaybackType() === Playback.LIVE);
12646
12652
  }
12647
12653
  _onProgress() {
12648
12654
  if (!this._dash) {
@@ -12655,7 +12661,7 @@ class DashPlayback extends HTML5Video {
12655
12661
  const progress = {
12656
12662
  start: this.getCurrentTime(),
12657
12663
  current: this.getCurrentTime() + buffer,
12658
- total: this.getDuration()
12664
+ total: this.getDuration(),
12659
12665
  };
12660
12666
  this.trigger(Events$1.PLAYBACK_PROGRESS, progress, {});
12661
12667
  }
@@ -12836,24 +12842,35 @@ class DashPlayback extends HTML5Video {
12836
12842
  height: currentLevel.height,
12837
12843
  width: currentLevel.width,
12838
12844
  bitrate: currentLevel.bitrate,
12839
- level: currentLevel.qualityIndex
12845
+ level: currentLevel.qualityIndex,
12840
12846
  });
12841
12847
  }
12842
12848
  getPlaybackType() {
12843
12849
  return this._playbackType;
12844
12850
  }
12845
12851
  isSeekEnabled() {
12846
- return (this._playbackType === Playback.VOD || this.dvrEnabled);
12852
+ return this._playbackType === Playback.VOD || this.dvrEnabled;
12847
12853
  }
12848
12854
  }
12849
12855
  DashPlayback.canPlay = function (resource, mimeType) {
12850
12856
  const resourceParts = resource.split('?')[0].match(/.*\.(.*)$/) || [];
12851
- const isDash = ((resourceParts.length > 1 && resourceParts[1].toLowerCase() === 'mpd') ||
12852
- mimeType === 'application/dash+xml' || mimeType === 'video/mp4');
12857
+ const isDash = (resourceParts.length > 1 && resourceParts[1].toLowerCase() === 'mpd') ||
12858
+ mimeType === 'application/dash+xml' ||
12859
+ mimeType === 'video/mp4';
12853
12860
  // TODO check
12854
- const ctor = window.MediaSource || ('WebKitMediaSource' in window ? window.WebKitMediaSource : undefined);
12861
+ const ms = window.MediaSource;
12862
+ const mms = 'ManagedMediaSource' in window ? window.ManagedMediaSource : undefined;
12863
+ const wms = 'WebKitMediaSource' in window ? window.WebKitMediaSource : undefined;
12864
+ const ctor = ms || mms || wms;
12855
12865
  const hasSupport = typeof ctor === 'function';
12856
- trace(`${T$2} canPlay`, { hasSupport, isDash, resource });
12866
+ trace(`${T$2} canPlay`, {
12867
+ hasSupport,
12868
+ isDash,
12869
+ resource,
12870
+ ms: typeof ms === 'function',
12871
+ mms: typeof mms === 'function',
12872
+ wms: typeof wms === 'function',
12873
+ });
12857
12874
  return !!(hasSupport && isDash);
12858
12875
  };
12859
12876
 
@@ -41439,7 +41456,8 @@ class Hls {
41439
41456
  Hls.defaultConfig = void 0;
41440
41457
 
41441
41458
  // assert(process.env.CLAPPR_VERSION, 'CLAPPR_VERSION is required');
41442
- const CLAPPR_VERSION = process.env.CLAPPR_VERSION || '0.11.3';
41459
+ // export const CLAPPR_VERSION: string = process.env.CLAPPR_VERSION || '0.11.3';
41460
+ const CLAPPR_VERSION = '0.11.3';
41443
41461
 
41444
41462
  // Copyright 2014 Globo.com Player authors. All rights reserved.
41445
41463
  // Use of this source code is governed by a BSD-style
@@ -42581,7 +42599,7 @@ class Player {
42581
42599
  this.qLevel = bitrate;
42582
42600
  });
42583
42601
  }
42584
- // TODO select a single source to play according to the priority transport and the modules support
42602
+ // Select a single source to play according to the priority transport and the modules support
42585
42603
  selectMediaSource() {
42586
42604
  return buildSourcesPriorityList(buildSourcesSet(this.config.sources), this.config.priorityTransport)[0];
42587
42605
  }
@@ -42709,12 +42727,12 @@ class SentryTracer {
42709
42727
  }
42710
42728
  }
42711
42729
 
42712
- var version$1 = "2.4.0";
42730
+ var version$1 = "2.4.2";
42713
42731
 
42714
42732
  var packages = {
42715
42733
  "": {
42716
42734
  name: "@gcorevideo/player",
42717
- version: "2.4.0",
42735
+ version: "2.4.2",
42718
42736
  license: "Apache-2.0",
42719
42737
  dependencies: {
42720
42738
  "@clappr/core": "^0.11.3",
package/lib/Player.js CHANGED
@@ -327,7 +327,7 @@ export class Player {
327
327
  this.qLevel = bitrate;
328
328
  });
329
329
  }
330
- // TODO select a single source to play according to the priority transport and the modules support
330
+ // Select a single source to play according to the priority transport and the modules support
331
331
  selectMediaSource() {
332
332
  return buildSourcesPriorityList(buildSourcesSet(this.config.sources), this.config.priorityTransport)[0];
333
333
  }
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,cAAc,EAAE,MAA+C,CAAC"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,EAAE,MAAiB,CAAC"}
package/lib/build.js CHANGED
@@ -1,2 +1,3 @@
1
1
  // assert(process.env.CLAPPR_VERSION, 'CLAPPR_VERSION is required');
2
- export const CLAPPR_VERSION = process.env.CLAPPR_VERSION || '0.11.3';
2
+ // export const CLAPPR_VERSION: string = process.env.CLAPPR_VERSION || '0.11.3';
3
+ export const CLAPPR_VERSION = '0.11.3';
@@ -1 +1 @@
1
- {"version":3,"file":"DashPlayback.d.ts","sourceRoot":"","sources":["../../../src/plugins/dash-playback/DashPlayback.ts"],"names":[],"mappings":"AAIA,OAAO,EAAU,UAAU,EAAO,QAAQ,EAA4B,MAAM,cAAc,CAAC;AAE3F,OAAO,MAAM,EAAG,EACd,UAAU,IAAI,cAAc,EAC5B,kBAAkB,IAAI,sBAAsB,EAC5C,KAAK,WAAW,EAEhB,aAAa,EACd,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAM5E,KAAK,YAAY,GACb,OAAO,QAAQ,CAAC,GAAG,GACnB,OAAO,QAAQ,CAAC,IAAI,GACpB,OAAO,QAAQ,CAAC,GAAG,GACnB,OAAO,QAAQ,CAAC,KAAK,CAAC;AAE1B,KAAK,YAAY,GAAG,MAAM,CAAC;AAE3B,KAAK,YAAY,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;I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,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,GAAG,IAAI,CAAO;IAE9D,IAAI,IAAI,WAEP;IAED,IAAI,MAAM,IAAI,YAAY,EAAE,CAE3B;IAED,IAAI,YAAY,IAAI,MAAM,CAMzB;IAED,IAAI,OAAO,YAEV;IAED,IAAI,YAAY,CAAC,EAAE,EAZC,MAYD,EAmClB;IAED,IAAI,UAAU,WASb;IAED,IAAI,IAAI,WAEP;IAID,IAAI,sBAAsB,WAczB;IAID,IAAI,oBAAoB,WAgBvB;IAED,IAAI,SAAS,WAKZ;gBAEW,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,GAAG;IAkDzD,MAAM;IAkEN,MAAM;IAMN,MAAM;IA8BN,SAAS;IAIT,qBAAqB;IAQrB,oBAAoB;IAMpB,kBAAkB;IAOlB,WAAW,IAAI,QAAQ;IAQvB,cAAc,IAAI,SAAS;IAU3B,kBAAkB,IAAI,SAAS;IAI/B,cAAc,CAAC,UAAU,EAAE,MAAM;IAejC,IAAI,CAAC,IAAI,EAAE,SAAS;IAgBpB,eAAe;IAIf,UAAU,CAAC,MAAM,EAAE,OAAO;IAK1B,eAAe;IAcf,gBAAgB,UAAW,sBAAsB,UAEhD;IAED,eAAe,UAAW,cAAc,UAwGvC;IAED,aAAa;IAqBb,iBAAiB;IAWjB,IAAI,UAAU,YASb;IAED,WAAW;IAmBX,IAAI;IAUJ,KAAK;IAWL,IAAI;IASJ,OAAO;IAkBP,mBAAmB;IAQnB,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE;IAqJjC,OAAO,CAAC,aAAa;IASrB,eAAe;IAIf,aAAa;CAGd"}
@@ -1,13 +1,13 @@
1
1
  // Copyright 2014 Globo.com Player authors. All rights reserved.
2
2
  // Use of this source code is governed by a BSD-style
3
3
  // license that can be found in the LICENSE file.
4
- import { Events, HTML5Video, Log, Playback, /* PlayerError, */ Utils } from '@clappr/core';
4
+ import { Events, HTML5Video, Log, Playback, Utils, } from '@clappr/core';
5
5
  import assert from 'assert'; // uses Node.js's assert types
6
6
  import DASHJS from 'dashjs';
7
7
  import { trace } from '../../trace/index.js';
8
8
  const AUTO = -1;
9
9
  const { now } = Utils;
10
- const T = "DashPlayback";
10
+ const T = 'DashPlayback';
11
11
  export default class DashPlayback extends HTML5Video {
12
12
  _levels = null;
13
13
  _currentLevel = null;
@@ -59,8 +59,8 @@ export default class DashPlayback extends HTML5Video {
59
59
  autoSwitchBitrate: {
60
60
  video: id === -1,
61
61
  },
62
- ABRStrategy: 'abrL2A'
63
- }
62
+ ABRStrategy: 'abrL2A',
63
+ },
64
64
  },
65
65
  };
66
66
  assert.ok(this._dash, 'An instance of dashjs MediaPlayer is required to switch levels');
@@ -81,7 +81,8 @@ export default class DashPlayback extends HTML5Video {
81
81
  }
82
82
  }
83
83
  get _startTime() {
84
- if (this._playbackType === Playback.LIVE && this._playlistType !== 'EVENT') {
84
+ if (this._playbackType === Playback.LIVE &&
85
+ this._playlistType !== 'EVENT') {
85
86
  return this._extrapolatedStartTime;
86
87
  }
87
88
  return this._playableRegionStartTime;
@@ -127,7 +128,8 @@ export default class DashPlayback extends HTML5Video {
127
128
  // Should be 2 or higher, or 0 to disable. Should only need to be increased above 2 if more than one segment is
128
129
  // removed from the start of the playlist at a time. E.g if the playlist is cached for 10 seconds and new chunks are
129
130
  // added/removed every 5.
130
- this._extrapolatedWindowNumSegments = this.options.playback?.extrapolatedWindowNumSegments ?? 2;
131
+ this._extrapolatedWindowNumSegments =
132
+ this.options.playback?.extrapolatedWindowNumSegments ?? 2;
131
133
  if (this.options.playbackType) {
132
134
  this._playbackType = this.options.playbackType;
133
135
  }
@@ -192,7 +194,8 @@ export default class DashPlayback extends HTML5Video {
192
194
  });
193
195
  this._dash.on(DASHJS.MediaPlayer.events.METRIC_ADDED, (e) => {
194
196
  // Listen for the first manifest request in order to update player UI
195
- if (e.metric === 'DVRInfo') { // TODO fix typings
197
+ if (e.metric === 'DVRInfo') {
198
+ // TODO fix typings
196
199
  assert.ok(this._dash, 'An instance of dashjs MediaPlayer is required to get metrics');
197
200
  const dvrInfo = this._dash.getDashMetrics().getCurrentDVRInfo('video');
198
201
  if (dvrInfo) {
@@ -297,7 +300,7 @@ export default class DashPlayback extends HTML5Video {
297
300
  }
298
301
  _updateDvr(status) {
299
302
  this.trigger(Events.PLAYBACK_DVR, status);
300
- this.trigger(Events.PLAYBACK_STATS_ADD, { 'dvr': status });
303
+ this.trigger(Events.PLAYBACK_STATS_ADD, { dvr: status });
301
304
  }
302
305
  _updateSettings() {
303
306
  if (this._playbackType === Playback.VOD) {
@@ -328,19 +331,19 @@ export default class DashPlayback extends HTML5Video {
328
331
  Log.error('The media cannot be played because it requires a feature ' +
329
332
  'that your browser does not support.');
330
333
  }
331
- else if (event.error === 'manifestError' && (
332
- // Manifest type not supported
333
- (event.event.id === 'createParser') ||
334
- // Codec(s) not supported
335
- (event.event.id === 'codec') ||
336
- // No streams available to stream
337
- (event.event.id === 'nostreams') ||
338
- // Error creating Stream object
339
- (event.event.id === 'nostreamscomposed') ||
340
- // syntax error parsing the manifest
341
- (event.event.id === 'parse') ||
342
- // a stream has multiplexed audio+video
343
- (event.event.id === 'multiplexedrep'))) {
334
+ else if (event.error === 'manifestError' &&
335
+ // Manifest type not supported
336
+ (event.event.id === 'createParser' ||
337
+ // Codec(s) not supported
338
+ event.event.id === 'codec' ||
339
+ // No streams available to stream
340
+ event.event.id === 'nostreams' ||
341
+ // Error creating Stream object
342
+ event.event.id === 'nostreamscomposed' ||
343
+ // syntax error parsing the manifest
344
+ event.event.id === 'parse' ||
345
+ // a stream has multiplexed audio+video
346
+ event.event.id === 'multiplexedrep')) {
344
347
  // These errors have useful error messages, so we forward it on
345
348
  const formattedError = this.createError(event.error);
346
349
  this.trigger(Events.PLAYBACK_ERROR, formattedError);
@@ -359,7 +362,8 @@ export default class DashPlayback extends HTML5Video {
359
362
  this.trigger(Events.PLAYBACK_ERROR, formattedError);
360
363
  Log.error(event.event);
361
364
  }
362
- else if (event.error === 'capability' && event.event === 'encryptedmedia') {
365
+ else if (event.error === 'capability' &&
366
+ event.event === 'encryptedmedia') {
363
367
  // Browser doesn't support EME
364
368
  const formattedError = this.createError(event.error);
365
369
  this.trigger(Events.PLAYBACK_ERROR, formattedError);
@@ -387,7 +391,7 @@ export default class DashPlayback extends HTML5Video {
387
391
  }
388
392
  else {
389
393
  // ignore the error
390
- if (typeof event.error === "object") {
394
+ if (typeof event.error === 'object') {
391
395
  const formattedError = this.createError(event.error);
392
396
  this.trigger(Events.PLAYBACK_ERROR, formattedError);
393
397
  Log.error(event.error.message);
@@ -411,10 +415,11 @@ export default class DashPlayback extends HTML5Video {
411
415
  const update = {
412
416
  current: this.getCurrentTime(),
413
417
  total: this.getDuration(),
414
- firstFragDateTime: this.getProgramDateTime()
418
+ firstFragDateTime: this.getProgramDateTime(),
415
419
  };
416
- const isSame = this._lastTimeUpdate && (update.current === this._lastTimeUpdate.current &&
417
- update.total === this._lastTimeUpdate.total);
420
+ const isSame = this._lastTimeUpdate &&
421
+ update.current === this._lastTimeUpdate.current &&
422
+ update.total === this._lastTimeUpdate.total;
418
423
  if (isSame) {
419
424
  return;
420
425
  }
@@ -431,7 +436,8 @@ export default class DashPlayback extends HTML5Video {
431
436
  }
432
437
  get dvrEnabled() {
433
438
  assert.ok(this._dash, 'An instance of dashjs MediaPlayer is required to get the DVR status');
434
- return this._dash?.getDVRWindowSize() >= this._minDvrSize && this.getPlaybackType() === Playback.LIVE;
439
+ return (this._dash?.getDVRWindowSize() >= this._minDvrSize &&
440
+ this.getPlaybackType() === Playback.LIVE);
435
441
  }
436
442
  _onProgress() {
437
443
  if (!this._dash) {
@@ -444,7 +450,7 @@ export default class DashPlayback extends HTML5Video {
444
450
  const progress = {
445
451
  start: this.getCurrentTime(),
446
452
  current: this.getCurrentTime() + buffer,
447
- total: this.getDuration()
453
+ total: this.getDuration(),
448
454
  };
449
455
  this.trigger(Events.PLAYBACK_PROGRESS, progress, {});
450
456
  }
@@ -625,23 +631,34 @@ export default class DashPlayback extends HTML5Video {
625
631
  height: currentLevel.height,
626
632
  width: currentLevel.width,
627
633
  bitrate: currentLevel.bitrate,
628
- level: currentLevel.qualityIndex
634
+ level: currentLevel.qualityIndex,
629
635
  });
630
636
  }
631
637
  getPlaybackType() {
632
638
  return this._playbackType;
633
639
  }
634
640
  isSeekEnabled() {
635
- return (this._playbackType === Playback.VOD || this.dvrEnabled);
641
+ return this._playbackType === Playback.VOD || this.dvrEnabled;
636
642
  }
637
643
  }
638
644
  DashPlayback.canPlay = function (resource, mimeType) {
639
645
  const resourceParts = resource.split('?')[0].match(/.*\.(.*)$/) || [];
640
- const isDash = ((resourceParts.length > 1 && resourceParts[1].toLowerCase() === 'mpd') ||
641
- mimeType === 'application/dash+xml' || mimeType === 'video/mp4');
646
+ const isDash = (resourceParts.length > 1 && resourceParts[1].toLowerCase() === 'mpd') ||
647
+ mimeType === 'application/dash+xml' ||
648
+ mimeType === 'video/mp4';
642
649
  // TODO check
643
- const ctor = window.MediaSource || ('WebKitMediaSource' in window ? window.WebKitMediaSource : undefined);
650
+ const ms = window.MediaSource;
651
+ const mms = 'ManagedMediaSource' in window ? window.ManagedMediaSource : undefined;
652
+ const wms = 'WebKitMediaSource' in window ? window.WebKitMediaSource : undefined;
653
+ const ctor = ms || mms || wms;
644
654
  const hasSupport = typeof ctor === 'function';
645
- trace(`${T} canPlay`, { hasSupport, isDash, resource });
655
+ trace(`${T} canPlay`, {
656
+ hasSupport,
657
+ isDash,
658
+ resource,
659
+ ms: typeof ms === 'function',
660
+ mms: typeof mms === 'function',
661
+ wms: typeof wms === 'function',
662
+ });
646
663
  return !!(hasSupport && isDash);
647
664
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gcorevideo/player",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "Gcore JavaScript video player",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
package/src/Player.ts CHANGED
@@ -408,7 +408,7 @@ export class Player {
408
408
  )
409
409
  }
410
410
 
411
- // TODO select a single source to play according to the priority transport and the modules support
411
+ // Select a single source to play according to the priority transport and the modules support
412
412
  private selectMediaSource(): PlayerMediaSource | undefined {
413
413
  return buildSourcesPriorityList(buildSourcesSet(this.config.sources), this.config.priorityTransport)[0]
414
414
  }
package/src/build.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  // assert(process.env.CLAPPR_VERSION, 'CLAPPR_VERSION is required');
2
- export const CLAPPR_VERSION: string = process.env.CLAPPR_VERSION || '0.11.3';
2
+ // export const CLAPPR_VERSION: string = process.env.CLAPPR_VERSION || '0.11.3';
3
+ export const CLAPPR_VERSION: string = '0.11.3';