';
- }
- }, {
- key: 'onSessionUpdate',
- value: function onSessionUpdate(isAlive) {
- if (!this.apiMedia) {
- return;
- }
- if (!isAlive) {
- return this.onStopAppSuccess();
- }
- }
- }, {
- key: 'onStopAppSuccess',
- value: function onStopAppSuccess() {
- this.stopTrackingCurrentTime();
- this.apiMedia = null;
- }
- }, {
- key: 'onMediaStatusUpdate',
- value: function onMediaStatusUpdate() {
- if (!this.apiMedia) {
- return;
- }
- switch (this.apiMedia.playerState) {
- case chrome.cast.media.PlayerState.BUFFERING:
- this.trigger('waiting');
- break;
- case chrome.cast.media.PlayerState.IDLE:
- this.trigger('timeupdate');
- this.trigger('ended');
-
- break;
- case chrome.cast.media.PlayerState.PAUSED:
- this.trigger('pause');
- this.paused_ = true;
- break;
- case chrome.cast.media.PlayerState.PLAYING:
- this.trigger('playing');
- this.trigger('play');
- this.paused_ = false;
- break;
- }
- }
-
- /**
- * Set video
- *
- * @param {Object=} src Source object
- * @method setSrc
- */
- }, {
- key: 'src',
- value: function src(_src) {}
- }, {
- key: 'currentSrc',
- value: function currentSrc() {
- if (!this.apiMedia) {
- return;
- }
- return this.apiMedia.media.contentId;
- }
- }, {
- key: 'handleAudioTracksChange',
- value: function handleAudioTracksChange() {
- var trackInfo = [];
- var tTracks = this.textTracks();
- var tracks = this.audioTracks();
-
- if (!tracks) {
- return;
- }
-
- for (var i = 0; i < tracks.length; i++) {
- var track = tracks[i];
- if (track['enabled']) {
- //set id of cuurentTrack audio
- trackInfo.push(i + 1 + tTracks.length);
- }
- }
-
- if (this.apiMedia && trackInfo.length) {
- this.tracksInfoRequest = new chrome.cast.media.EditTracksInfoRequest(trackInfo);
- return this.apiMedia.editTracksInfo(this.tracksInfoRequest, this.onTrackSuccess.bind(this), this.onTrackError.bind(this));
- }
- }
- }, {
- key: 'handleVideoTracksChange',
- value: function handleVideoTracksChange() {}
- }, {
- key: 'handleTextTracksChange',
- value: function handleTextTracksChange() {
- var trackInfo = [];
- var tracks = this.textTracks();
-
- if (!tracks) {
- return;
- }
-
- for (var i = 0; i < tracks.length; i++) {
- var track = tracks[i];
- if (track['mode'] === 'showing') {
- trackInfo.push(i + 1);
- }
- }
-
- if (this.apiMedia && trackInfo.length) {
- this.tracksInfoRequest = new chrome.cast.media.EditTracksInfoRequest(trackInfo);
- return this.apiMedia.editTracksInfo(this.tracksInfoRequest, this.onTrackSuccess.bind(this), this.onTrackError.bind(this));
- }
- }
- }, {
- key: 'onTrackSuccess',
- value: function onTrackSuccess() {
- return _videoJs2['default'].log('track added');
- }
- }, {
- key: 'onTrackError',
- value: function onTrackError(e) {
- return _videoJs2['default'].log('Cast track Error: ' + JSON.stringify(e));
- }
- }, {
- key: 'castError',
- value: function castError(e) {
- return _videoJs2['default'].log('Cast Error: ' + JSON.stringify(e));
- }
- }, {
- key: 'play',
- value: function play() {
- if (!this.apiMedia) {
- return;
- }
- if (this.paused_) {
- this.apiMedia.play(null, this.mediaCommandSuccessCallback.bind(this, 'Playing: ' + this.apiMedia.sessionId), this.castError.bind(this));
- }
- return this.paused_ = false;
- }
- }, {
- key: 'pause',
- value: function pause() {
- if (!this.apiMedia) {
- return;
- }
- if (!this.paused_) {
- this.apiMedia.pause(null, this.mediaCommandSuccessCallback.bind(this, 'Paused: ' + this.apiMedia.sessionId), this.castError.bind(this));
- return this.paused_ = true;
- }
- }
- }, {
- key: 'paused',
- value: function paused() {
- return this.paused_;
- }
- }, {
- key: 'ended',
- value: function ended() {
- return chrome.cast.media.IdleReason === "FINISHED";
- }
- }, {
- key: 'currentTime',
- value: function currentTime() {
- if (!this.apiMedia) {
- return 0;
- }
- return this.apiMedia.getEstimatedTime();
- }
- }, {
- key: 'setCurrentTime',
- value: function setCurrentTime(position) {
-
- if (!this.apiMedia) {
- return 0;
- }
- var request = undefined;
- request = new chrome.cast.media.SeekRequest();
- request.currentTime = position;
- //if (this.player_.controlBar.progressControl.seekBar.videoWasPlaying) {
- // request.resumeState = chrome.cast.media.ResumeState.PLAYBACK_START;
- //}
- return this.apiMedia.seek(request, this.onSeekSuccess.bind(this, position), this.castError.bind(this));
- }
- }, {
- key: 'onSeekSuccess',
- value: function onSeekSuccess(position) {
- _videoJs2['default'].log('seek success' + position);
- }
- }, {
- key: 'volume',
- value: function volume() {
- return this.volume_;
- }
- }, {
- key: 'duration',
- value: function duration() {
- if (!this.apiMedia) {
- return 0;
- }
- return this.apiMedia.media.duration || Infinity;
- }
- }, {
- key: 'controls',
- value: function controls() {
- return false;
- }
- }, {
- key: 'setVolume',
- value: function setVolume(level) {
- var mute = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
-
- var request = undefined;
- var volume = undefined;
- if (!this.apiMedia) {
- return;
- }
- volume = new chrome.cast.Volume();
- volume.level = level;
- volume.muted = mute;
- this.volume_ = volume.level;
- this.muted_ = mute;
- request = new chrome.cast.media.VolumeRequest();
- request.volume = volume;
- this.apiMedia.setVolume(request, this.mediaCommandSuccessCallback.bind(this, 'Volume changed'), this.castError.bind(this));
- return this.trigger('volumechange');
- }
- }, {
- key: 'mediaCommandSuccessCallback',
- value: function mediaCommandSuccessCallback(information) {
- _videoJs2['default'].log(information);
- }
- }, {
- key: 'muted',
- value: function muted() {
- return this.muted_;
- }
- }, {
- key: 'setMuted',
- value: function setMuted(muted) {
- return this.setVolume(this.volume_, muted);
- }
- }, {
- key: 'supportsFullScreen',
- value: function supportsFullScreen() {
- return false;
- }
- }, {
- key: 'resetSrc_',
- value: function resetSrc_(callback) {
- callback();
- }
- }, {
- key: 'dispose',
- value: function dispose() {
- this.resetSrc_(Function.prototype);
- _get(Object.getPrototypeOf(Chromecast.prototype), 'dispose', this).call(this, this);
- }
- }]);
-
- return Chromecast;
-})(Tech);
-
-Chromecast.prototype.paused_ = false;
-
-Chromecast.prototype.options_ = {};
-
-Chromecast.prototype.timerStep = 1000;
-
-/* Chromecast Support Testing -------------------------------------------------------- */
-
-Chromecast.isSupported = function () {
- return true;
-};
-
-// Add Source Handler pattern functions to this tech
-Tech.withSourceHandlers(Chromecast);
-
-/*
- * The default native source handler.
- * This simply passes the source to the video element. Nothing fancy.
- *
- * @param {Object} source The source object
- * @param {Flash} tech The instance of the Flash tech
- */
-Chromecast.nativeSourceHandler = {};
-
-/**
- * Check if Flash can play the given videotype
- * @param {String} type The mimetype to check
- * @return {String} 'probably', 'maybe', or '' (empty string)
- */
-Chromecast.nativeSourceHandler.canPlayType = function (source) {
-
- var dashTypeRE = /^application\/(?:dash\+xml|(x-|vnd\.apple\.)mpegurl)/i;
- var dashExtRE = /^video\/(mpd|mp4|webm|m3u8)/i;
-
- if (dashTypeRE.test(source)) {
- return 'probably';
- } else if (dashExtRE.test(source)) {
- return 'maybe';
- } else {
- return '';
- }
-};
-
-/*
- * Check Flash can handle the source natively
- *
- * @param {Object} source The source object
- * @return {String} 'probably', 'maybe', or '' (empty string)
- */
-Chromecast.nativeSourceHandler.canHandleSource = function (source) {
-
- // If a type was provided we should rely on that
- if (source.type) {
- return Chromecast.nativeSourceHandler.canPlayType(source.type);
- } else if (source.src) {
- return Chromecast.nativeSourceHandler.canPlayType(source.src);
- }
-
- return '';
-};
-
-/*
- * Pass the source to the flash object
- * Adaptive source handlers will have more complicated workflows before passing
- * video data to the video element
- *
- * @param {Object} source The source object
- * @param {Flash} tech The instance of the Flash tech
- */
-Chromecast.nativeSourceHandler.handleSource = function (source, tech) {
- tech.src(source.src);
-};
-
-/*
- * Clean up the source handler when disposing the player or switching sources..
- * (no cleanup is needed when supporting the format natively)
- */
-Chromecast.nativeSourceHandler.dispose = function () {};
-
-// Register the native source handler
-Chromecast.registerSourceHandler(Chromecast.nativeSourceHandler);
-
-/*
- * Set the tech's volume control support status
- *
- * @type {Boolean}
- */
-Chromecast.prototype['featuresVolumeControl'] = true;
-
-/*
- * Set the tech's playbackRate support status
- *
- * @type {Boolean}
- */
-Chromecast.prototype['featuresPlaybackRate'] = false;
-
-/*
- * Set the tech's status on moving the video element.
- * In iOS, if you move a video element in the DOM, it breaks video playback.
- *
- * @type {Boolean}
- */
-Chromecast.prototype['movingMediaElementInDOM'] = false;
-
-/*
- * Set the the tech's fullscreen resize support status.
- * HTML video is able to automatically resize when going to fullscreen.
- * (No longer appears to be used. Can probably be removed.)
- */
-Chromecast.prototype['featuresFullscreenResize'] = false;
-
-/*
- * Set the tech's timeupdate event support status
- * (this disables the manual timeupdate events of the Tech)
- */
-Chromecast.prototype['featuresTimeupdateEvents'] = false;
-
-/*
- * Set the tech's progress event support status
- * (this disables the manual progress events of the Tech)
- */
-Chromecast.prototype['featuresProgressEvents'] = false;
-
-/*
- * Sets the tech's status on native text track support
- *
- * @type {Boolean}
- */
-Chromecast.prototype['featuresNativeTextTracks'] = true;
-
-/*
- * Sets the tech's status on native audio track support
- *
- * @type {Boolean}
- */
-Chromecast.prototype['featuresNativeAudioTracks'] = true;
-
-/*
- * Sets the tech's status on native video track support
- *
- * @type {Boolean}
- */
-Chromecast.prototype['featuresNativeVideoTracks'] = false;
-
-_videoJs2['default'].options.chromecast = {};
-
-Tech.registerTech('Chromecast', Chromecast);
-
-exports['default'] = Chromecast;
-module.exports = exports['default'];
-}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{}],3:[function(require,module,exports){
-(function (global){
-/**
- * ! videojs-chromecast - v1.0.0 - 2016-02-15
- * Copyright (c) 2015 benjipott
- * Licensed under the Apache-2.0 license.
- * @file videojs-chromecast.js
- **/
-'use strict';
-
-Object.defineProperty(exports, '__esModule', {
- value: true
-});
-
-var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
-
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
-
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
-
-function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-var _videoJs = (typeof window !== "undefined" ? window['videojs'] : typeof global !== "undefined" ? global['videojs'] : null);
-
-var _videoJs2 = _interopRequireDefault(_videoJs);
-
-var _componentControlBarChromecastButton = require('./component/control-bar/chromecast-button');
-
-var _componentControlBarChromecastButton2 = _interopRequireDefault(_componentControlBarChromecastButton);
-
-var _techChromecast = require('./tech/chromecast');
-
-var _techChromecast2 = _interopRequireDefault(_techChromecast);
-
-var Component = _videoJs2['default'].getComponent('Component');
-
-/**
- * Initialize the plugin.
- * @param options (optional) {object} configuration for the plugin
- */
-
-var Chromecast = (function (_Component) {
- _inherits(Chromecast, _Component);
-
- function Chromecast(player, options) {
- _classCallCheck(this, Chromecast);
-
- _get(Object.getPrototypeOf(Chromecast.prototype), 'constructor', this).call(this, player, options);
- }
-
- return Chromecast;
-})(Component);
-
-Chromecast.prototype.options_ = {};
-
-// register the plugin
-_videoJs2['default'].options.children.push('chromecast');
-
-_videoJs2['default'].addLanguage('en', {
- 'CASTING TO': 'WIEDERGABE AUF'
-});
-
-_videoJs2['default'].addLanguage('de', {
- 'CASTING TO': 'WIEDERGABE AUF'
-});
-
-_videoJs2['default'].addLanguage('it', {
- 'CASTING TO': 'PLAYBACK SU'
-});
-
-_videoJs2['default'].addLanguage('fr', {
- 'CASTING TO': 'CAST EN COURS SUR'
-});
-
-Component.registerComponent('Chromecast', Chromecast);
-exports['default'] = Chromecast;
-module.exports = exports['default'];
-}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{"./component/control-bar/chromecast-button":1,"./tech/chromecast":2}],4:[function(require,module,exports){
-(function (global){
-'use strict';
-
-Object.defineProperty(exports, '__esModule', {
- value: true
-});
-
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
-
-var _videoJs = (typeof window !== "undefined" ? window['videojs'] : typeof global !== "undefined" ? global['videojs'] : null);
-
-var _videoJs2 = _interopRequireDefault(_videoJs);
-
-var _videojsChromecast = require('./videojs-chromecast');
-
-var _videojsChromecast2 = _interopRequireDefault(_videojsChromecast);
-
-/**
- * The video.js playlist plugin. Invokes the playlist-maker to create a
- * playlist function on the specific player.
- *
- * @param {Array} list
- */
-var plugin = function plugin(options) {
- var player = this;
- player.addChild('Chromecast', options);
-};
-
-var registerPlugin = _videoJs2['default'].registerPlugin || _videoJs2['default'].plugin;
-
-registerPlugin('chromecast', plugin);
-
-exports['default'] = plugin;
-module.exports = exports['default'];
-}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{"./videojs-chromecast":3}]},{},[4])(4)
-});
\ No newline at end of file
diff --git a/dist/videojs-chromecast.min.js b/dist/videojs-chromecast.min.js
deleted file mode 100644
index c8b3c90..0000000
--- a/dist/videojs-chromecast.min.js
+++ /dev/null
@@ -1,7 +0,0 @@
-/**
- * videojs-chromecast
- * @version 2.0.8
- * @copyright 2018 Benjipott, Inc.
- * @license Apache-2.0
- */
-!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,(t.video||(t.video={})).jsChromecast=e()}}(function(){return function e(t,i,o){function n(r,s){if(!i[r]){if(!t[r]){var c="function"==typeof require&&require;if(!s&&c)return c(r,!0);if(a)return a(r,!0);var u=new Error("Cannot find module '"+r+"'");throw u.code="MODULE_NOT_FOUND",u}var d=i[r]={exports:{}};t[r][0].call(d.exports,function(e){var i=t[r][1][e];return n(i||e)},d,d.exports,e,t,i,o)}return i[r].exports}for(var a="function"==typeof require&&require,r=0;r