Skip to content

Commit

Permalink
Merge pull request #2 from GuacLive/changelog-v1.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
datagutt authored Feb 25, 2023
2 parents 3acc31f + 2533a61 commit 226cc90
Show file tree
Hide file tree
Showing 7 changed files with 2,000 additions and 914 deletions.
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,36 @@
All notable changes to this project will be documented in this file.
See [our coding standards][commit-messages] for commit guidelines.

## 1.13.0 (2023-02-25)


### Features

* Add support for livestreams ([9a4710b](https://github.com/guaclive/videojs-chromecast/commit/9a4710b3dcc7afa0ec16dabe4893d6d302d9abe6))
* added tracks support, added session restoring support ([157b067](https://github.com/guaclive/videojs-chromecast/commit/157b067da97e2b3dcff8adc61666d3c5bd899cb2)), closes [/github.com/silvermine/videojs-chromecast/pull/89#pullrequestreview-645475948](https://github.com/guaclive//github.com/silvermine/videojs-chromecast/pull/89/issues/pullrequestreview-645475948)
* Allow modifying the load request ([85fc983](https://github.com/guaclive/videojs-chromecast/commit/85fc983acfa8ed961166879630b4d372b5f1c00b))
* customizable content URL ([f7f8437](https://github.com/guaclive/videojs-chromecast/commit/f7f84379ef75cfa1553b112b5e2782458a218861))


### Bug Fixes

* clean event listeners on player.dispose() ([#97](https://github.com/guaclive/videojs-chromecast/issues/97)) ([328c141](https://github.com/guaclive/videojs-chromecast/commit/328c141f4cf3ce65492b6beb511b0592585aefcd))
* correctly fire ended event ([fbcda9b](https://github.com/guaclive/videojs-chromecast/commit/fbcda9bee7774d1d62236d59c34ecb8f1d8cdf1e))
* downgrade class.extend to avoid unsafe-eval ([#52](https://github.com/guaclive/videojs-chromecast/issues/52)) ([4aaec89](https://github.com/guaclive/videojs-chromecast/commit/4aaec8900a865cb19f6e7df51a507b12bb6a48d7))
* error because tech.seeking was not defined ([3bb0698](https://github.com/guaclive/videojs-chromecast/commit/3bb06984edee57997436ac89f714274779d11731))
* missing `preload` function ([#30](https://github.com/guaclive/videojs-chromecast/issues/30)) ([c1bda1b](https://github.com/guaclive/videojs-chromecast/commit/c1bda1b59d93958f5b51fc3f857cdabf70e03a3e))
* remove deprecated `.extend` method ([708bdbd](https://github.com/guaclive/videojs-chromecast/commit/708bdbd23526aa041d784c63af3aadc0b769004e)), closes [#152](https://github.com/guaclive/videojs-chromecast/issues/152) [#147](https://github.com/guaclive/videojs-chromecast/issues/147)
* scrubbing workaround ([4cbf71f](https://github.com/guaclive/videojs-chromecast/commit/4cbf71f0a05958df2a8f8d95540350caac1b15e7))
* scss deprecation warning ([e345639](https://github.com/guaclive/videojs-chromecast/commit/e34563986162b66955a0ce8147387755f49e40b3))
* typo ([4124a0c](https://github.com/guaclive/videojs-chromecast/commit/4124a0c3b691aa5062825bd6cb88892212caa882))
* update package name ([ef678bb](https://github.com/guaclive/videojs-chromecast/commit/ef678bb40eaf0b0af504df5bc184c6eae048619f))


### Reverts

* Revert "1.12.0" ([53258b3](https://github.com/guaclive/videojs-chromecast/commit/53258b34f8c9c35c814c0c06a5cf655f38f9f323))


## 1.13.0 (2022-09-21)


Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@
"sinon": "2.3.5"
},
"peerDependencies": {
"video.js": ">= 6 < 8"
"video.js": ">= 6 < 9"
}
}
318 changes: 179 additions & 139 deletions src/js/components/ChromecastButton.js
Original file line number Diff line number Diff line change
@@ -1,156 +1,196 @@
/**
* The ChromecastButton module contains both the ChromecastButton class definition and
* the function used to register the button as a Video.js Component.
*
* @module ChromecastButton
*/

var ChromecastButton;

/**
* The Video.js Button class is the base class for UI button components.
*
* @external Button
* @see {@link http://docs.videojs.com/Button.html|Button}
*/

/** @lends ChromecastButton.prototype */
ChromecastButton = {

/**
* This class is a button component designed to be displayed in the player UI's control
* bar. It opens the Chromecast menu when clicked.
*
* @constructs
* @extends external:Button
* @param player {Player} the video.js player instance
*/
constructor: function(player) {
this.constructor.super_.apply(this, arguments);

player.on('chromecastConnected', this._onChromecastConnected.bind(this));
player.on('chromecastDisconnected', this._onChromecastDisconnected.bind(this));
player.on('chromecastDevicesAvailable', this._onChromecastDevicesAvailable.bind(this));
player.on('chromecastDevicesUnavailable', this._onChromecastDevicesUnavailable.bind(this));

this.controlText('Open Chromecast menu');
module.exports = function (videojs) {
/**
* Registers the ChromecastButton Component with Video.js. Calls
* {@link http://docs.videojs.com/Component.html#.registerComponent}, which will add a
* component called `chromecastButton` to the list of globally registered Video.js
* components. The `chromecastButton` is added to the player's control bar UI
* automatically once {@link module:enableChromecast} has been called. If you would
* like to specify the order of the buttons that appear in the control bar, including
* this button, you can do so in the options that you pass to the `videojs` function
* when creating a player:
*
* ```
* videojs('playerID', {
* controlBar: {
* children: [
* 'playToggle',
* 'progressControl',
* 'volumePanel',
* 'fullscreenToggle',
* 'chromecastButton',
* ],
* }
* });
* ```
*
* @param videojs {object} A reference to {@link http://docs.videojs.com/module-videojs.html|Video.js}
* @see http://docs.videojs.com/module-videojs.html#~registerPlugin
*/

/**
* The Video.js Button class is the base class for UI button components.
*
* @external Button
* @see {@link http://docs.videojs.com/Button.html|Button}
*/
const ButtonComponent = videojs.getComponent("Button");

/**
* The ChromecastButton module contains both the ChromecastButton class definition and
* the function used to register the button as a Video.js Component.
* @module ChromecastButton
*/

/** @lends ChromecastButton.prototype **/
class ChromecastButton extends ButtonComponent {
/**
* This class is a button component designed to be displayed in the
* player UI's control bar. It opens the Chromecast menu when clicked.
*
* @constructs
* @extends external:Button
* @param player {Player} the video.js player instance
*/
constructor(player, options) {
super(player, options);

player.on("chromecastConnected", this._onChromecastConnected.bind(this));
player.on(
"chromecastDisconnected",
this._onChromecastDisconnected.bind(this)
);
player.on(
"chromecastDevicesAvailable",
this._onChromecastDevicesAvailable.bind(this)
);
player.on(
"chromecastDevicesUnavailable",
this._onChromecastDevicesUnavailable.bind(this)
);

// Use the initial state of `hasAvailableDevices` to call the corresponding event
// handlers because the corresponding events may have already been emitted before
// binding the listeners above.
if (player.chromecastSessionManager && player.chromecastSessionManager.hasAvailableDevices()) {
this._onChromecastDevicesAvailable();
if (
player.chromecastSessionManager &&
player.chromecastSessionManager.hasAvailableDevices()
) {
this._onChromecastDevicesAvailable();
} else {
this._onChromecastDevicesUnavailable();
this._onChromecastDevicesUnavailable();
}
},

/**
* Overrides Button#buildCSSClass to return the classes used on the button element.
*
* @param el {DOMElement}
* @see {@link http://docs.videojs.com/Button.html#buildCSSClass|Button#buildCSSClass}
*/
buildCSSClass: function() {
return 'vjs-chromecast-button ' + (this._isChromecastConnected ? 'vjs-chromecast-casting-state ' : '') +
this.constructor.super_.prototype.buildCSSClass();
},

/**
* Overrides Button#handleClick to handle button click events. Chromecast functionality
* is handled outside of this class, which should be limited to UI related logic. This
* function simply triggers an event on the player.
*
* @fires ChromecastButton#chromecastRequested
* @param el {DOMElement}
* @see {@link http://docs.videojs.com/Button.html#handleClick|Button#handleClick}
*/
handleClick: function() {
this.player().trigger('chromecastRequested');
},

/**
* Handles `chromecastConnected` player events.
*
* @private
*/
_onChromecastConnected: function() {

if (options.addCastLabelToButton) {
this.el().classList.add("vjs-chromecast-button-lg");

this._labelEl = document.createElement("span");
this._labelEl.classList.add("vjs-chromecast-button-label");
this._updateCastLabelText();

this.el().appendChild(this._labelEl);
} else {
this.controlText("Open Chromecast menu");
}
}

/**
* Overrides Button#buildCSSClass to return the classes used on the button element.
*
* @param el {DOMElement}
* @see {@link http://docs.videojs.com/Button.html#buildCSSClass|Button#buildCSSClass}
*/
buildCSSClass() {
return (
"vjs-chromecast-button " +
(this._isChromecastConnected ? "vjs-chromecast-casting-state " : "") +
(this.options_.addCastLabelToButton
? "vjs-chromecast-button-lg "
: "") +
ButtonComponent.prototype.buildCSSClass()
);
}

/**
* Overrides Button#handleClick to handle button click events. Chromecast
* functionality is handled outside of this class, which should be limited
* to UI related logic. This function simply triggers an event on the player.
*
* @fires ChromecastButton#chromecastRequested
* @param el {DOMElement}
* @see {@link http://docs.videojs.com/Button.html#handleClick|Button#handleClick}
*/
handleClick() {
this.player().trigger("chromecastRequested");
}

/**
* Handles `chromecastConnected` player events.
*
* @private
*/
_onChromecastConnected() {
this._isChromecastConnected = true;
this._reloadCSSClasses();
},

/**
* Handles `chromecastDisconnected` player events.
*
* @private
*/
_onChromecastDisconnected: function() {
this._updateCastLabelText();
}

/**
* Handles `chromecastDisconnected` player events.
*
* @private
*/
_onChromecastDisconnected() {
this._isChromecastConnected = false;
this._reloadCSSClasses();
},

/**
* Handles `chromecastDevicesAvailable` player events.
*
* @private
*/
_onChromecastDevicesAvailable: function() {
this._updateCastLabelText();
}

/**
* Handles `chromecastDevicesAvailable` player events.
*
* @private
*/
_onChromecastDevicesAvailable() {
this.show();
},

/**
* Handles `chromecastDevicesUnavailable` player events.
*
* @private
*/
_onChromecastDevicesUnavailable: function() {
}

/**
* Handles `chromecastDevicesUnavailable` player events.
*
* @private
*/
_onChromecastDevicesUnavailable() {
this.hide();
},

/**
* Re-calculates which CSS classes the button needs and sets them on the buttons'
* DOMElement.
*
* @private
*/
_reloadCSSClasses: function() {
}

/**
* Re-calculates which CSS classes the button needs and sets them on the buttons'
* DOMElement.
*
* @private
*/
_reloadCSSClasses() {
if (!this.el_) {
return;
return;
}
this.el_.className = this.buildCSSClass();
},
};
}

/**
* Updates the optional cast label text based on whether the chromecast is connected
* or disconnected.
*
* @private
*/
_updateCastLabelText() {
if (!this._labelEl) {
return;
}
this._labelEl.textContent = this._isChromecastConnected
? this.localize("Disconnect Cast")
: this.localize("Cast");
}
}

/**
* Registers the ChromecastButton Component with Video.js. Calls
* {@link http://docs.videojs.com/Component.html#.registerComponent}, which will add a
* component called `chromecastButton` to the list of globally registered Video.js
* components. The `chromecastButton` is added to the player's control bar UI
* automatically once {@link module:enableChromecast} has been called. If you would like
* to specify the order of the buttons that appear in the control bar, including this
* button, you can do so in the options that you pass to the `videojs` function when
* creating a player:
*
* ```
* videojs('playerID', {
* controlBar: {
* children: [
* 'playToggle',
* 'progressControl',
* 'volumePanel',
* 'fullscreenToggle',
* 'chromecastButton',
* ],
* }
* });
* ```
*
* @param videojs {object} A reference to {@link http://docs.videojs.com/module-videojs.html|Video.js}
* @see http://docs.videojs.com/module-videojs.html#~registerPlugin
*/
module.exports = function(videojs) {
var ChromecastButtonImpl;

ChromecastButtonImpl = videojs.extend(videojs.getComponent('Button'), ChromecastButton);
videojs.registerComponent('chromecastButton', ChromecastButtonImpl);
videojs.registerComponent("chromecastButton", ChromecastButton);
};
Loading

0 comments on commit 226cc90

Please sign in to comment.