@eluvio/elv-player-js 2.0.23 → 2.0.24

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.
@@ -7,17 +7,23 @@ class Cast {
7
7
  this.onReady = onReady;
8
8
  this.connected = false;
9
9
  this.playbackRate = 1;
10
-
11
- window["__onGCastApiAvailable"] = isAvailable =>
12
- isAvailable && this.Initialize();
13
-
14
- window.CastController = this;
15
-
16
10
  this.__listeners = [];
17
-
18
11
  this.onUpdate = onUpdate;
19
12
 
20
- this.LoadScript();
13
+ if(window.__chromecastAvailable || (window.chrome && window.chrome.cast)) {
14
+ // Chromecast already initialized
15
+ this.Initialize();
16
+ } else {
17
+ // Initialize chromecast script
18
+ window["__onGCastApiAvailable"] = isAvailable => {
19
+ if(isAvailable) {
20
+ window.__chromecastAvailable = true;
21
+ this.Initialize();
22
+ }
23
+ };
24
+
25
+ this.LoadScript();
26
+ }
21
27
  }
22
28
 
23
29
  LoadScript() {
@@ -68,7 +74,7 @@ class Cast {
68
74
  async SetMedia({playoutOptions, playoutParameters}) {
69
75
  // Get dash options
70
76
  let dashOptions = ((playoutOptions || {}).dash || {}).playoutMethods || {};
71
- let options = dashOptions.clear || dashOptions.widevine;
77
+ let options = dashOptions.clear;
72
78
 
73
79
  if(!options) {
74
80
  // Dash options might be available under the default_dash offering
@@ -79,7 +85,7 @@ class Cast {
79
85
  });
80
86
 
81
87
  dashOptions = ((playoutOptions || {}).dash || {}).playoutMethods || {};
82
- options = dashOptions.clear || dashOptions.widevine || {};
88
+ options = dashOptions.clear || {};
83
89
  } catch(error) {
84
90
  this.player.Log("Unable to find dash playout options for chromecast");
85
91
  }
@@ -7,6 +7,8 @@ import {MergeDefaultParameters} from "../ui/Common";
7
7
 
8
8
  const isIOS = /iPhone|iPad|iPod/i.test(navigator.userAgent);
9
9
 
10
+ const chromecastAvailable = window.__chromecastAvailable || !!(window.chrome && window.chrome.cast);
11
+
10
12
  const PlayerProfiles = {
11
13
  default: {
12
14
  label: "Default",
@@ -60,8 +62,12 @@ export class EluvioPlayer {
60
62
  this.behindLiveEdge = false;
61
63
  this.publicMetadataUrl = undefined;
62
64
  this.airplayAvailable = false;
63
- this.chromecastAvailable = false;
65
+ this.chromecastAvailable = chromecastAvailable;
64
66
  this.casting = false;
67
+ this.usePlayerControls = [
68
+ EluvioPlayerParameters.controls.ON,
69
+ EluvioPlayerParameters.controls.AUTO_HIDE
70
+ ].includes(parameters.playerOptions.controls);
65
71
 
66
72
  try {
67
73
  // If custom HLS parameters are specified, set profile to custom
@@ -342,17 +348,19 @@ export class EluvioPlayer {
342
348
  }
343
349
  }
344
350
 
345
- // Handle Chromecast
346
- this.castHandler = new Cast({
347
- player: this,
348
- onReady: () => {
349
- this.chromecastAvailable = true;
350
- this.__SettingsUpdate();
351
- },
352
- onUpdate: () => {
353
- this.__SettingsUpdate();
354
- }
355
- });
351
+ // Handle Chromecast (Only if player controls will be visible)
352
+ if(this.usePlayerControls) {
353
+ this.castHandler = new Cast({
354
+ player: this,
355
+ onReady: () => {
356
+ this.chromecastAvailable = true;
357
+ this.__SettingsUpdate();
358
+ },
359
+ onUpdate: () => {
360
+ this.__SettingsUpdate();
361
+ }
362
+ });
363
+ }
356
364
 
357
365
  // Detect Airplay availability
358
366
  this.__RegisterVideoEventListener("webkitplaybacktargetavailabilitychanged", event => {
@@ -407,10 +415,12 @@ export class EluvioPlayer {
407
415
 
408
416
  this.playoutUrl = playoutUrl.toString();
409
417
 
410
- this.castHandler.SetMedia({
411
- playoutOptions: this.sourceOptions.playoutOptions,
412
- playoutParameters
413
- });
418
+ if(this.castHandler) {
419
+ this.castHandler.SetMedia({
420
+ playoutOptions: this.sourceOptions.playoutOptions,
421
+ playoutParameters
422
+ });
423
+ }
414
424
 
415
425
  if(this.__destroyed) { return; }
416
426
 
@@ -1026,7 +1036,7 @@ export class EluvioPlayer {
1026
1036
  }
1027
1037
 
1028
1038
  __DestroyPlayer() {
1029
- this.castHandler.Disconnect();
1039
+ this.castHandler && this.castHandler.Disconnect();
1030
1040
  this.__destroyed = true;
1031
1041
  this.__Reset();
1032
1042
  }
@@ -1086,7 +1096,7 @@ export class EluvioPlayer {
1086
1096
  this.dvrEnabled = false;
1087
1097
  this.publicMetadataUrl = undefined;
1088
1098
  this.airplayAvailable = false;
1089
- this.chromecastAvailable = false;
1099
+ this.chromecastAvailable = chromecastAvailable;
1090
1100
  this.casting = false;
1091
1101
  }
1092
1102
 
@@ -85,7 +85,7 @@ export const ObserveVideo = ({player, setVideoState}) => {
85
85
  events.map(event => player.video.addEventListener(event, UpdateVideoState));
86
86
  player.target.addEventListener("fullscreenchange", UpdateVideoState);
87
87
 
88
- const castListenerDisposer = player.castHandler.RegisterListener(UpdateVideoState);
88
+ const castListenerDisposer = player.castHandler && player.castHandler.RegisterListener(UpdateVideoState);
89
89
 
90
90
  return () => {
91
91
  events.map(event => player.video.removeEventListener(event, UpdateVideoState));
@@ -45,7 +45,7 @@ const TimeIndicator = ({player, videoState}) => {
45
45
  `${Time(currentTime, videoState.duration)} / `
46
46
  }
47
47
  {
48
- !player.dvrEnabled ? null :
48
+ (player.isLive && !player.dvrEnabled) ? null :
49
49
  Time(videoState.duration, videoState.duration)
50
50
  }
51
51
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-player-js",
3
- "version": "2.0.23",
3
+ "version": "2.0.24",
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",