3 exports.__esModule = true;
5 var _component = require('../component.js');
7 var _component2 = _interopRequireDefault(_component);
9 var _tech = require('./tech.js');
11 var _tech2 = _interopRequireDefault(_tech);
13 var _toTitleCase = require('../utils/to-title-case.js');
15 var _toTitleCase2 = _interopRequireDefault(_toTitleCase);
17 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
19 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
21 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; }
23 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; } /**
29 * The `MediaLoader` is the `Component` that decides which playback technology to load
30 * when a player is initialized.
34 var MediaLoader = function (_Component) {
35 _inherits(MediaLoader, _Component);
38 * Create an instance of this class.
40 * @param {Player} player
41 * The `Player` that this class should attach to.
43 * @param {Object} [options]
44 * The key/value stroe of player options.
46 * @param {Component~ReadyCallback} [ready]
47 * The function that is run when this component is ready.
49 function MediaLoader(player, options, ready) {
50 _classCallCheck(this, MediaLoader);
52 // If there are no sources when the player is initialized,
53 // load the first supported playback technology.
55 var _this = _possibleConstructorReturn(this, _Component.call(this, player, options, ready));
57 if (!options.playerOptions.sources || options.playerOptions.sources.length === 0) {
58 for (var i = 0, j = options.playerOptions.techOrder; i < j.length; i++) {
59 var techName = (0, _toTitleCase2['default'])(j[i]);
60 var tech = _tech2['default'].getTech(techName);
62 // Support old behavior of techs being registered as components.
63 // Remove once that deprecated behavior is removed.
65 tech = _component2['default'].getComponent(techName);
68 // Check if the browser supports this technology
69 if (tech && tech.isSupported()) {
70 player.loadTech_(techName);
75 // Loop through playback technologies (HTML5, Flash) and check for support.
76 // Then load the best source.
77 // A few assumptions here:
78 // All playback technologies respect preload false.
79 player.src(options.playerOptions.sources);
85 }(_component2['default']);
87 _component2['default'].registerComponent('MediaLoader', MediaLoader);
88 exports['default'] = MediaLoader;