text: 'use strict';
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  
  var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  
  var _react = require('react');
  
  var _react2 = _interopRequireDefault(_react);
  
  var _props2 = require('./props');
  
  var _utils = require('./utils');
  
  var _players = require('./players');
  
  var _players2 = _interopRequireDefault(_players);
  
  var _Player3 = require('./Player');
  
  var _Player4 = _interopRequireDefault(_Player3);
  
  var _FilePlayer = require('./players/FilePlayer');
  
  var _FilePlayer2 = _interopRequireDefault(_FilePlayer);
  
  var _preload = require('./preload');
  
  var _preload2 = _interopRequireDefault(_preload);
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  
  function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  
  function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  
  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 SUPPORTED_PROPS = Object.keys(_props2.propTypes);
  
  var ReactPlayer = function (_Component) {
    _inherits(ReactPlayer, _Component);
  
    function ReactPlayer() {
      var _ref;
  
      var _temp, _this, _ret;
  
      _classCallCheck(this, ReactPlayer);
  
      for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
        args[_key] = arguments[_key];
      }
  
      return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = ReactPlayer.__proto__ || Object.getPrototypeOf(ReactPlayer)).call.apply(_ref, [this].concat(args))), _this), _this.config = (0, _utils.getConfig)(_this.props, _props2.defaultProps, true), _this.getDuration = function () {
        if (!_this.player) return null;
        return _this.player.getDuration();
      }, _this.getCurrentTime = function () {
        if (!_this.player) return null;
        return _this.player.getCurrentTime();
      }, _this.getInternalPlayer = function () {
        var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'player';
  
        if (!_this.player) return null;
        return _this.player.getInternalPlayer(key);
      }, _this.seekTo = function (fraction) {
        if (!_this.player) return null;
        _this.player.seekTo(fraction);
      }, _this.progress = function () {
        if (_this.props.url && _this.player && _this.player.isReady) {
          var playedSeconds = _this.player.getCurrentTime() || 0;
          var loadedSeconds = _this.player.getSecondsLoaded();
          var duration = _this.player.getDuration();
          if (duration) {
            var progress = {
              playedSeconds: playedSeconds,
              played: playedSeconds / duration
            };
            if (loadedSeconds !== null) {
              progress.loadedSeconds = loadedSeconds;
              progress.loaded = loadedSeconds / duration;
            }
            // Only call onProgress if values have changed
            if (progress.played !== _this.prevPlayed || progress.loaded !== _this.prevLoaded) {
              _this.props.onProgress(progress);
            }
            _this.prevPlayed = progress.played;
            _this.prevLoaded = progress.loaded;
          }
        }
        _this.progressTimeout = setTimeout(_this.progress, _this.props.progressFrequency);
      }, _this.wrapperRef = function (wrapper) {
        _this.wrapper = wrapper;
      }, _this.activePlayerRef = function (player) {
        _this.player = player;
      }, _temp), _possibleConstructorReturn(_this, _ret);
    }
  
    _createClass(ReactPlayer, [{
      key: 'componentDidMount',
      value: function componentDidMount() {
        this.progress();
      }
    }, {
      key: 'componentWillUnmount',
      value: function componentWillUnmount() {
        clearTimeout(this.progressTimeout);
      }
    }, {
      key: 'shouldComponentUpdate',
      value: function shouldComponentUpdate(nextProps) {
        var _iteratorNormalCompletion = true;
        var _didIteratorError = false;
        var _iteratorError = undefined;
  
        try {
          for (var _iterator = Object.keys(this.props)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
            var key = _step.value;
  
            var prop = this.props[key];
            if (!(0, _utils.isObject)(prop) && prop !== nextProps[key]) {
              return true;
            }
          }
        } catch (err) {
          _didIteratorError = true;
          _iteratorError = err;
        } finally {
          try {
            if (!_iteratorNormalCompletion && _iterator['return']) {
              _iterator['return']();
            }
          } finally {
            if (_didIteratorError) {
              throw _iteratorError;
            }
          }
        }
  
        return false;
      }
    }, {
      key: 'getActivePlayer',
      value: function getActivePlayer(url) {
        var _iteratorNormalCompletion2 = true;
        var _didIteratorError2 = false;
        var _iteratorError2 = undefined;
  
        try {
          for (var _iterator2 = _players2['default'][Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
            var _Player = _step2.value;
  
            if (_Player.canPlay(url)) {
              return _Player;
            }
          }
          // Fall back to FilePlayer if nothing else can play the URL
        } catch (err) {
          _didIteratorError2 = true;
          _iteratorError2 = err;
        } finally {
          try {
            if (!_iteratorNormalCompletion2 && _iterator2['return']) {
              _iterator2['return']();
            }
          } finally {
            if (_didIteratorError2) {
              throw _iteratorError2;
            }
          }
        }
  
        return _FilePlayer2['default'];
      }
    }, {
      key: 'renderActivePlayer',
      value: function renderActivePlayer(url) {
        if (!url) return null;
        var activePlayer = this.getActivePlayer(url);
        return _react2['default'].createElement(_Player4['default'], _extends({}, this.props, {
          key: activePlayer.displayName,
          ref: this.activePlayerRef,
          config: this.config,
          activePlayer: activePlayer
        }));
      }
    }, {
      key: 'sortPlayers',
      value: function sortPlayers(a, b) {
        // Retain player order to prevent weird iframe behaviour when switching players
        if (a && b) {
          return a.key < b.key ? -1 : 1;
        }
        return 0;
      }
    }, {
      key: 'render',
      value: function render() {
        var _props = this.props,
            url = _props.url,
            style = _props.style,
            width = _props.width,
            height = _props.height;
  
        var otherProps = (0, _utils.omit)(this.props, SUPPORTED_PROPS, _props2.DEPRECATED_CONFIG_PROPS);
        var activePlayer = this.renderActivePlayer(url);
        var preloadPlayers = (0, _preload2['default'])(url, this.config);
        var players = [activePlayer].concat(_toConsumableArray(preloadPlayers)).sort(this.sortPlayers);
        return _react2['default'].createElement(
          'div',
          _extends({ ref: this.wrapperRef, style: _extends({}, style, { width: width, height: height }) }, otherProps),
          players
        );
      }
    }]);
  
    return ReactPlayer;
  }(_react.Component);
  
  ReactPlayer.displayName = 'ReactPlayer';
  ReactPlayer.propTypes = _props2.propTypes;
  ReactPlayer.defaultProps = _props2.defaultProps;
  
  ReactPlayer.canPlay = function (url) {
    var _iteratorNormalCompletion3 = true;
    var _didIteratorError3 = false;
    var _iteratorError3 = undefined;
  
    try {
      for (var _iterator3 = _players2['default'][Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
        var _Player2 = _step3.value;
  
        if (_Player2.canPlay(url)) {
          return true;
        }
      }
    } catch (err) {
      _didIteratorError3 = true;
      _iteratorError3 = err;
    } finally {
      try {
        if (!_iteratorNormalCompletion3 && _iterator3['return']) {
          _iterator3['return']();
        }
      } finally {
        if (_didIteratorError3) {
          throw _iteratorError3;
        }
      }
    }
  
    return false;
  };
  
  exports['default'] = ReactPlayer;