Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@silvermine/videojs-chromecast

Package Overview
Dependencies
Maintainers
3
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@silvermine/videojs-chromecast - npm Package Compare versions

Comparing version 1.3.3 to 1.3.4

.browserslistrc

24

package.json
{
"name": "@silvermine/videojs-chromecast",
"version": "1.3.3",
"version": "1.3.4",
"description": "video.js plugin for casting to chromecast",

@@ -8,3 +8,10 @@ "main": "src/js/index.js",

"commitlint": "commitlint --from d4e7f7e",
"test": "check-node-version --npm 6.14.12 && nyc mocha -- -R spec 'tests/**/*.test.js'",
"test": "check-node-version --npm 8.5.5 && nyc mocha -- -R spec 'tests/**/*.test.js'",
"stylelint": "stylelint './src/scss/**/*.scss'",
"eslint": "eslint '{,!(node_modules|dist)/**/}*.js'",
"markdownlint": "markdownlint -c .markdownlint.json -i CHANGELOG.md '{,!(node_modules)/**/}*.md'",
"standards": "npm run markdownlint && npm run stylelint && npm run eslint",
"release:preview": "node ./node_modules/@silvermine/standardization/scripts/release.js preview",
"release:prep-changelog": "node ./node_modules/@silvermine/standardization/scripts/release.js prep-changelog",
"release:finalize": "node ./node_modules/@silvermine/standardization/scripts/release.js finalize",
"prepublish": "grunt build"

@@ -31,10 +38,16 @@ },

"dependencies": {
"class.extend": "0.9.1",
"webcomponents.js": "git+https://git@github.com/webcomponents/webcomponentsjs.git#v0.7.24"
},
"devDependencies": {
"@babel/core": "7.13.16",
"@babel/preset-env": "7.13.15",
"@commitlint/cli": "8.3.5",
"@commitlint/travis-cli": "8.3.5",
"@silvermine/eslint-config": "3.0.1",
"@silvermine/standardization": "1.1.0",
"@silvermine/standardization": "2.0.0",
"autoprefixer": "7.1.1",
"babel-eslint": "10.1.0",
"babelify": "10.0.0",
"check-node-version": "4.0.3",
"core-js": "3.11.0",
"coveralls": "3.0.2",

@@ -49,3 +62,2 @@ "eslint": "6.8.0",

"grunt-contrib-watch": "1.1.0",
"grunt-eslint": "22.0.0",
"grunt-postcss": "0.9.0",

@@ -55,5 +67,5 @@ "grunt-sass": "3.1.0",

"mocha-lcov-reporter": "1.3.0",
"node-sass": "6.0.0",
"nyc": "15.1.0",
"rewire": "2.5.2",
"sass": "1.52.3",
"silvermine-serverless-utils": "git+https://github.com/silvermine/serverless-utils.git#910f1149af824fc8d0fa840878079c7d3df0f414",

@@ -60,0 +72,0 @@ "sinon": "2.3.5"

@@ -56,17 +56,17 @@ # Silvermine VideoJS Chromecast Plugin

* **`preloadWebComponents`** (default: `false`) - The Chromecast framework relies on the
`webcomponents.js` polyfill when a browser does not have `document.registerElement` in
order to create the `<google-cast-button>` custom component (which is not used by this
plugin). If you are using jQuery, this polyfill must be loaded and initialized before
jQuery is initialized. Unfortunately, the Chromecast framework loads the
`webcomponents.js` polyfill via a dynamically created `<script>` tag. This causes a race
condition (see #17). Also, including `webcomponents.js` anywhere on the page will break
jQuery's fix for bubbling some events to `document` (e.g. `onchange` events for
`<select>`, see #21). Setting `preloadWebComponents` to `true` will "fix" these 2
problems by (1) making this plugin add the `webcomponents` polyfill synchronously when
the polyfill is needed and (2) using the `webcomponents-lite.js` version as it does not
include the shadow DOM polyfills, but still provides the `registerElement` polyfill that
the Chromecast framework needs. If you use the `preloadWebComponents: true` option, you
should make sure that this plugin is loaded before jQuery. Then include the Chromecast
framework after this plugin as you normally would.
* **`preloadWebComponents`** (default: `false`) - The Chromecast framework relies on the
`webcomponents.js` polyfill when a browser does not have `document.registerElement` in
order to create the `<google-cast-button>` custom component (which is not used by this
plugin). If you are using jQuery, this polyfill must be loaded and initialized before
jQuery is initialized. Unfortunately, the Chromecast framework loads the
`webcomponents.js` polyfill via a dynamically created `<script>` tag. This causes a race
condition (see #17). Also, including `webcomponents.js` anywhere on the page will break
jQuery's fix for bubbling some events to `document` (e.g. `onchange` events for
`<select>`, see #21). Setting `preloadWebComponents` to `true` will "fix" these 2
problems by (1) making this plugin add the `webcomponents` polyfill synchronously when
the polyfill is needed and (2) using the `webcomponents-lite.js` version as it does not
include the shadow DOM polyfills, but still provides the `registerElement` polyfill that
the Chromecast framework needs. If you use the `preloadWebComponents: true` option, you
should make sure that this plugin is loaded before jQuery. Then include the Chromecast
framework after this plugin as you normally would.

@@ -154,33 +154,35 @@ **Note:** There is a caveat to using the `preloadWebComponents` setting.

##### Plugin configuration
* **`plugins.chromecast.receiverAppID`** - the string ID of a custom [Chromecast receiver
app][cast-receiver] to use. Defaults to the [default Media Receiver ID][def-cast-id].
* **`plugins.chromecast.addButtonToControlBar`** - a `boolean` flag that tells the plugin
whether or not it should automatically add the Chromecast button to the Video.js
player's control bar component. Defaults to `true`.
* **`plugins.chromecast.buttonPositionIndex`** - a zero-based number specifying the index
of the Chromecast button among the control bar's child components (if
`addButtonToControlBar` is set to `true`). By default the Chromecast Button is added as
the last child of the control bar. A value less than 0 puts the button at the specified
position from the end of the control bar. Note that it's likely not all child components
of the control bar are visible.
* **`plugins.chromecast.receiverAppID`** - the string ID of a custom [Chromecast receiver
app][cast-receiver] to use. Defaults to the [default Media Receiver ID][def-cast-id].
* **`plugins.chromecast.addButtonToControlBar`** - a `boolean` flag that tells the plugin
whether or not it should automatically add the Chromecast button to the Video.js
player's control bar component. Defaults to `true`.
* **`plugins.chromecast.buttonPositionIndex`** - a zero-based number specifying the index
of the Chromecast button among the control bar's child components (if
`addButtonToControlBar` is set to `true`). By default the Chromecast Button is added as
the last child of the control bar. A value less than 0 puts the button at the specified
position from the end of the control bar. Note that it's likely not all child components
of the control bar are visible.
##### Chromecast Tech configuration
* **`chromecast.requestTitleFn`** - a function that this plugin calls when it needs a
string that will be the title shown in the UI that is shown when a Chromecast session is
active and connected. When the this plugin calls the `requestTitleFn`, it passes it the
[current `source` object][player-source] and expects a string in return. If nothing is
returned or if this option is not defined, no title will be shown.
* **`chromecast.requestSubtitleFn`** - a function that this plugin calls when it needs a
string that will be the sub-title shown in the UI that is shown when a Chromecast
session is active and connected. When the this plugin calls the `requestSubtitleFn`, it
passes it the [current `source` object][player-source] and expects a string in return.
If nothing is returned or if this option is not defined, no sub-title will be shown.
* **`chromecast.requestCustomDataFn`** - a function that this plugin calls when it needs an
object that contains custom information necessary for a Chromecast receiver app when a
session is active and connected. When the this plugin calls the `requestCustomDataFn`, it
passes it the [current `source` object][player-source] and expects an object in return.
If nothing is returned or if this option is not defined, no custom data will be sent.
This option is intended to be used with a [custom receiver][custom-receiver] application
to extend its default capabilities.
* **`chromecast.requestTitleFn`** - a function that this plugin calls when it needs a
string that will be the title shown in the UI that is shown when a Chromecast session
is active and connected. When the this plugin calls the `requestTitleFn`, it passes it
the [current `source` object][player-source] and expects a string in return. If nothing
is returned or if this option is not defined, no title will be shown.
* **`chromecast.requestSubtitleFn`** - a function that this plugin calls when it needs a
string that will be the sub-title shown in the UI that is shown when a Chromecast
session is active and connected. When the this plugin calls the `requestSubtitleFn`, it
passes it the [current `source` object][player-source] and expects a string in return.
If nothing is returned or if this option is not defined, no sub-title will be shown.
* **`chromecast.requestCustomDataFn`** - a function that this plugin calls when it needs
an object that contains custom information necessary for a Chromecast receiver app when
a session is active and connected. When the this plugin calls the `requestCustomDataFn`,
it passes it the [current `source` object][player-source] and expects an object in return.
If nothing is returned or if this option is not defined, no custom data will be sent.
This option is intended to be used with a [custom receiver][custom-receiver] application
to extend its default capabilities.
Here is an example configuration object that makes full use of all required and optional

@@ -272,26 +274,26 @@ configuration:

* **`$icon-chromecast--default`** - the path to the icon image that is displayed when the
Chromecast button is in its normal, default state. Defaults to
`"images/ic_cast_white_24dp.png"`.
* **`$icon-chromecast--hover`** - the path to the icon image that is displayed when the
user hovers over the Chromecast button when it is in its normal, default state. Defaults
to `"images/ic_cast_white_24dp.png"`.
* **`$icon-chromecast-casting`** - the path to the icon image that is displayed when the
Chromecast button is in the "casting" state (when a Chromecast session is active and
connected). Defaults to `"images/ic_cast_connected_white_24dp.png"`.
* **`$icon-chromecast-casting--hover`** - the path to the icon image that is displayed
when the user hovers over the Chromecast button when it is in the "casting" state (when
a Chromecast session is active and connected). Defaults to
`"images/ic_cast_connected_white_24dp.png"`.
* **`$chromecast-icon-size`** - the width and height of the icon (the button and icon is a
square). Defaults to `12px`.
* **`$chromecast-title-font-size`** - the font size of the title on the screen that is
shown while a Chromecast session is active and connected. Defaults to `22px`.
* **`$chromecast-subtitle-font-size`** - the font size of the sub-title on the screen
that is shown while a Chromecast session is active and connected. Defaults to `18px`.
* **`$chromecast-poster-width`** - the width of the poster image on the screen that that
is shown while a Chromecast session is active and connected. Defaults to `100px`.
* **`$chromecast-poster-max-height`** - the maximum height of the poster image on the
screen that is shown while a Chromecast session is active and connected. Defaults to
`180px`.
* **`$icon-chromecast--default`** - the path to the icon image that is displayed when the
Chromecast button is in its normal, default state. Defaults to
`"images/ic_cast_white_24dp.png"`.
* **`$icon-chromecast--hover`** - the path to the icon image that is displayed when the
user hovers over the Chromecast button when it is in its normal, default state. Defaults
to `"images/ic_cast_white_24dp.png"`.
* **`$icon-chromecast-casting`** - the path to the icon image that is displayed when the
Chromecast button is in the "casting" state (when a Chromecast session is active and
connected). Defaults to `"images/ic_cast_connected_white_24dp.png"`.
* **`$icon-chromecast-casting--hover`** - the path to the icon image that is displayed
when the user hovers over the Chromecast button when it is in the "casting" state (when
a Chromecast session is active and connected). Defaults to
`"images/ic_cast_connected_white_24dp.png"`.
* **`$chromecast-icon-size`** - the width and height of the icon (the button and icon is
a square). Defaults to `12px`.
* **`$chromecast-title-font-size`** - the font size of the title on the screen that is
shown while a Chromecast session is active and connected. Defaults to `22px`.
* **`$chromecast-subtitle-font-size`** - the font size of the sub-title on the screen
that is shown while a Chromecast session is active and connected. Defaults to `18px`.
* **`$chromecast-poster-width`** - the width of the poster image on the screen that that
is shown while a Chromecast session is active and connected. Defaults to `100px`.
* **`$chromecast-poster-max-height`** - the maximum height of the poster image on the
screen that is shown while a Chromecast session is active and connected.
Defaults to `180px`.

@@ -308,3 +310,3 @@

In addition the the `ic_cast_white_24dp.png` icon image that is used as the default icon for
In addition, the `ic_cast_white_24dp.png` icon image that is used as the default icon for
all four button states ("default", "default + hover", "casting", "casting + hover"), the `images`

@@ -314,2 +316,11 @@ folder contains grey, black, and blue versions of the icons.

### Events
*`chromecastConnected`: Triggers when Chromecast connected
*`chromecastDisconnected`: Triggers when Chromecast disconnected
*`chromecastDevicesAvailable`: Triggers on state change when Chromecast devices are available
*`chromecastDevicesUnavailable`: Triggers on state change when Chromecast devices are unavailable
*`chromecastRequested`: Triggers when the user has requested Chromecast playback using this
plugin's Chromecast button
## How do I contribute?

@@ -316,0 +327,0 @@

@@ -1,13 +0,4 @@

'use strict';
/** @lends ChromecastSessionManager.prototype **/
class ChromecastSessionManager {
var Class = require('class.extend'),
hasConnected = false, // See the `isChromecastConnected` function.
ChromecastSessionManager;
function getCastContext() {
return cast.framework.CastContext.getInstance();
}
ChromecastSessionManager = Class.extend(/** @lends ChromecastSessionManager.prototype **/ {
/**

@@ -40,3 +31,3 @@ * Stores the state of the current Chromecast session and its associated objects such

*/
init: function(player) {
constructor(player) {
this.player = player;

@@ -57,4 +48,6 @@

this.remotePlayerController = new cast.framework.RemotePlayerController(this.remotePlayer);
},
}
static hasConnected = false;
/**

@@ -65,3 +58,3 @@ * Add event listeners for events triggered on the current CastContext.

*/
_addCastContextEventListeners: function() {
_addCastContextEventListeners() {
var sessionStateChangedEvt = cast.framework.CastContextEventType.SESSION_STATE_CHANGED,

@@ -72,3 +65,3 @@ castStateChangedEvt = cast.framework.CastContextEventType.CAST_STATE_CHANGED;

this.getCastContext().addEventListener(castStateChangedEvt, this._castListener);
},
}

@@ -81,3 +74,3 @@ /**

*/
_removeCastContextEventListeners: function() {
_removeCastContextEventListeners() {
var sessionStateChangedEvt = cast.framework.CastContextEventType.SESSION_STATE_CHANGED,

@@ -88,3 +81,3 @@ castStateChangedEvt = cast.framework.CastContextEventType.CAST_STATE_CHANGED;

this.getCastContext().removeEventListener(castStateChangedEvt, this._castListener);
},
}

@@ -96,3 +89,3 @@ /**

*/
_onSessionStateChange: function(event) {
_onSessionStateChange(event) {
if (event.sessionState === cast.framework.SessionState.SESSION_ENDED) {

@@ -102,3 +95,3 @@ this.player.trigger('chromecastDisconnected');

}
},
}

@@ -110,5 +103,5 @@ /**

*/
_onCastStateChange: function(event) {
_onCastStateChange(event) {
this._notifyPlayerOfDevicesAvailabilityChange(event.castState);
},
}

@@ -121,3 +114,3 @@ /**

*/
_notifyPlayerOfDevicesAvailabilityChange: function(castState) {
_notifyPlayerOfDevicesAvailabilityChange(castState) {
if (this.hasAvailableDevices(castState)) {

@@ -128,3 +121,3 @@ this.player.trigger('chromecastDevicesAvailable');

}
},
}

@@ -138,3 +131,3 @@ /**

*/
hasAvailableDevices: function(castState) {
hasAvailableDevices(castState) {
castState = castState || this.getCastContext().getCastState();

@@ -145,3 +138,3 @@

castState === cast.framework.CastState.CONNECTED;
},
}

@@ -152,3 +145,3 @@ /**

*/
openCastMenu: function() {
openCastMenu() {
var onSessionSuccess;

@@ -161,3 +154,3 @@

onSessionSuccess = function() {
hasConnected = true;
ChromecastSessionManager.hasConnected = true;
this.player.trigger('chromecastConnected');

@@ -176,3 +169,3 @@ this._reloadTech();

.then(onSessionSuccess, function() { /* noop */ });
},
}

@@ -189,3 +182,3 @@ /**

*/
_reloadTech: function() {
_reloadTech() {
var player = this.player,

@@ -211,3 +204,3 @@ currentTime = player.currentTime(),

});
},
}

@@ -218,4 +211,7 @@ /**

*/
getCastContext: getCastContext,
getCastContext() {
return cast.framework.CastContext.getInstance();
}
/**

@@ -225,5 +221,5 @@ * @see https://developers.google.com/cast/docs/reference/chrome/cast.framework.RemotePlayer

*/
getRemotePlayer: function() {
getRemotePlayer() {
return this.remotePlayer;
},
}

@@ -234,34 +230,33 @@ /**

*/
getRemotePlayerController: function() {
getRemotePlayerController() {
return this.remotePlayerController;
},
});
}
/**
* Returns whether or not the current Chromecast API is available (that is,
* `window.chrome`, `window.chrome.cast`, and `window.cast` exist).
*
* @static
* @returns {boolean} true if the Chromecast API is available
*/
static isChromecastAPIAvailable() {
return window.chrome && window.chrome.cast && window.cast;
}
/**
* Returns whether or not the current Chromecast API is available (that is,
* `window.chrome`, `window.chrome.cast`, and `window.cast` exist).
*
* @static
* @returns {boolean} true if the Chromecast API is available
*/
ChromecastSessionManager.isChromecastAPIAvailable = function() {
return window.chrome && window.chrome.cast && window.cast;
};
/**
* Returns whether or not there is a current CastSession and it is connected.
*
* @static
* @returns {boolean} true if the current CastSession exists and is connected
*/
static isChromecastConnected() {
// We must also check the `hasConnected` flag because
// `getCastContext().getCastState()` returns `CONNECTED` even when the current
// casting session was initiated by another tab in the browser or by another process
return ChromecastSessionManager.isChromecastAPIAvailable() &&
(cast.framework.CastContext.getInstance().getCastState() === cast.framework.CastState.CONNECTED) &&
ChromecastSessionManager.hasConnected;
}
}
/**
* Returns whether or not there is a current CastSession and it is connected.
*
* @static
* @returns {boolean} true if the current CastSession exists and is connected
*/
ChromecastSessionManager.isChromecastConnected = function() {
// We must also check the `hasConnected` flag because
// `getCastContext().getCastState()` returns `CONNECTED` even when the current casting
// session was initiated by another tab in the browser or by another process.
return ChromecastSessionManager.isChromecastAPIAvailable() &&
(getCastContext().getCastState() === cast.framework.CastState.CONNECTED) &&
hasConnected;
};
module.exports = ChromecastSessionManager;

@@ -1,3 +0,1 @@

'use strict';
/**

@@ -4,0 +2,0 @@ * The ChromecastButton module contains both the ChromecastButton class definition and

@@ -1,3 +0,1 @@

'use strict';
/**

@@ -4,0 +2,0 @@ * @module enableChromecast

/* eslint-disable global-require */
'use strict';
var preloadWebComponents = require('./preloadWebComponents'),

@@ -5,0 +3,0 @@ createChromecastButton = require('./components/ChromecastButton'),

@@ -1,3 +0,1 @@

'use strict';
function doesUserAgentContainString(str) {

@@ -4,0 +2,0 @@ return typeof window.navigator.userAgent === 'string' && window.navigator.userAgent.indexOf(str) >= 0;

@@ -1,3 +0,1 @@

'use strict';
// This file is used to create a standalone javascript file for use in a script tag. The

@@ -4,0 +2,0 @@ // file that is output assumes that Video.js is available at `window.videojs`.

@@ -1,3 +0,1 @@

'use strict';
var ChromecastSessionManager = require('../chromecast/ChromecastSessionManager'),

@@ -746,4 +744,4 @@ ChromecastTechUI = require('./ChromecastTechUI'),

// TODO Consider a more comprehensive check based on mimetype.
ChromecastTechImpl.canPlaySource = ChromecastSessionManager.isChromecastConnected.bind(ChromecastSessionManager);
ChromecastTechImpl.isSupported = ChromecastSessionManager.isChromecastConnected.bind(ChromecastSessionManager);
ChromecastTechImpl.canPlaySource = () => { return ChromecastSessionManager.isChromecastConnected(); };
ChromecastTechImpl.isSupported = () => { return ChromecastSessionManager.isChromecastConnected(); };

@@ -750,0 +748,0 @@ ChromecastTechImpl.prototype.featuresVolumeControl = true;

@@ -1,6 +0,1 @@

'use strict';
var Class = require('class.extend'),
ChromecastTechUI;
/**

@@ -14,6 +9,6 @@ * This class represents the UI that is shown in the player while the Chromecast Tech is

*/
ChromecastTechUI = Class.extend(/** @lends ChromecastTechUI.prototype */ {
init: function() {
class ChromecastTechUI {
constructor() {
this._el = this._createDOMElement();
},
}

@@ -27,3 +22,3 @@ /**

*/
_createDOMElement: function() {
_createDOMElement() {
var el = this._createElement('div', 'vjs-tech vjs-tech-chromecast'),

@@ -44,3 +39,3 @@ posterContainerEl = this._createElement('div', 'vjs-tech-chromecast-poster'),

return el;
},
}

@@ -56,3 +51,3 @@ /**

*/
_createElement: function(type, className) {
_createElement(type, className) {
var el = document.createElement(type);

@@ -62,3 +57,3 @@

return el;
},
}

@@ -70,5 +65,5 @@ /**

*/
getDOMElement: function() {
getDOMElement() {
return this._el;
},
}

@@ -81,5 +76,5 @@ /**

*/
_findPosterEl: function() {
_findPosterEl() {
return this._el.querySelector('.vjs-tech-chromecast-poster');
},
}

@@ -92,5 +87,5 @@ /**

*/
_findPosterImageEl: function() {
_findPosterImageEl() {
return this._el.querySelector('.vjs-tech-chromecast-poster-img');
},
}

@@ -103,5 +98,5 @@ /**

*/
_findTitleEl: function() {
_findTitleEl() {
return this._el.querySelector('.vjs-tech-chromecast-title');
},
}

@@ -114,5 +109,5 @@ /**

*/
_findSubtitleEl: function() {
_findSubtitleEl() {
return this._el.querySelector('.vjs-tech-chromecast-subtitle');
},
}

@@ -125,3 +120,3 @@ /**

*/
updatePoster: function(poster) {
updatePoster(poster) {
var posterImageEl = this._findPosterImageEl();

@@ -137,3 +132,3 @@

}
},
}

@@ -145,5 +140,5 @@ /**

*/
getPoster: function() {
getPoster() {
return this._poster;
},
}

@@ -155,3 +150,3 @@ /**

*/
updateTitle: function(title) {
updateTitle(title) {
var titleEl = this._findTitleEl();

@@ -166,3 +161,3 @@

}
},
}

@@ -174,3 +169,3 @@ /**

*/
updateSubtitle: function(subtitle) {
updateSubtitle(subtitle) {
var subtitleEl = this._findSubtitleEl();

@@ -185,5 +180,5 @@

}
},
});
}
}
module.exports = ChromecastTechUI;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc