Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Commit

Permalink
Merge pull request #46 from Faithlife/master
Browse files Browse the repository at this point in the history
Store and check whether receiver is available
  • Loading branch information
benjipott committed Jan 23, 2018
2 parents 04f5f12 + a319e7b commit 3c62d9e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
10 changes: 10 additions & 0 deletions dist/videojs-chromecast.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var _videoJs2 = _interopRequireDefault(_videoJs);
var Component = _videoJs2['default'].getComponent('Component');
var ControlBar = _videoJs2['default'].getComponent('ControlBar');
var Button = _videoJs2['default'].getComponent('Button');
var hasReceiver = false;

/**
* The base class for buttons that toggle chromecast video
Expand Down Expand Up @@ -133,6 +134,11 @@ var ChromeCastButton = (function (_Button) {
}, {
key: 'onInitSuccess',
value: function onInitSuccess() {
if (hasReceiver) {
this.show();
} else {
this.hide();
}
return this.apiInitialized = true;
}
}, {
Expand All @@ -148,7 +154,11 @@ var ChromeCastButton = (function (_Button) {
key: 'receiverListener',
value: function receiverListener(availability) {
if (availability === 'available') {
hasReceiver = true;
return this.show();
} else {
hasReceiver = false;
return this.hide();
}
}
}, {
Expand Down
2 changes: 1 addition & 1 deletion dist/videojs-chromecast.min.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions es5/js/component/control-bar/chromecast-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var _videoJs2 = _interopRequireDefault(_videoJs);
var Component = _videoJs2['default'].getComponent('Component');
var ControlBar = _videoJs2['default'].getComponent('ControlBar');
var Button = _videoJs2['default'].getComponent('Button');
var hasReceiver = false;

/**
* The base class for buttons that toggle chromecast video
Expand Down Expand Up @@ -125,6 +126,11 @@ var ChromeCastButton = (function (_Button) {
}, {
key: 'onInitSuccess',
value: function onInitSuccess() {
if (hasReceiver) {
this.show();
} else {
this.hide();
}
return this.apiInitialized = true;
}
}, {
Expand All @@ -140,7 +146,11 @@ var ChromeCastButton = (function (_Button) {
key: 'receiverListener',
value: function receiverListener(availability) {
if (availability === 'available') {
hasReceiver = true;
return this.show();
} else {
hasReceiver = false;
return this.hide();
}
}
}, {
Expand Down
10 changes: 10 additions & 0 deletions src/js/component/control-bar/chromecast-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import videojs from 'video.js';
const Component = videojs.getComponent('Component');
const ControlBar = videojs.getComponent('ControlBar');
const Button = videojs.getComponent('Button');
let hasReceiver = false;

/**
* The base class for buttons that toggle chromecast video
Expand Down Expand Up @@ -97,6 +98,11 @@ class ChromeCastButton extends Button {
}

onInitSuccess () {
if (hasReceiver) {
this.show();
} else {
this.hide();
}
return this.apiInitialized = true;
}

Expand All @@ -110,7 +116,11 @@ class ChromeCastButton extends Button {

receiverListener (availability) {
if (availability === 'available') {
hasReceiver = true;
return this.show();
} else {
hasReceiver = false;
return this.hide();
}
}

Expand Down

0 comments on commit 3c62d9e

Please sign in to comment.