1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 |
|
7 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
|
8 |
|
9 | var _playlistJs = require('./playlist.js');
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | var enableFunction = function enableFunction(loader, playlistUri, changePlaylistFn) {
|
24 | return function (enable) {
|
25 | var playlist = loader.master.playlists[playlistUri];
|
26 | var incompatible = (0, _playlistJs.isIncompatible)(playlist);
|
27 | var currentlyEnabled = (0, _playlistJs.isEnabled)(playlist);
|
28 |
|
29 | if (typeof enable === 'undefined') {
|
30 | return currentlyEnabled;
|
31 | }
|
32 |
|
33 | if (enable) {
|
34 | delete playlist.disabled;
|
35 | } else {
|
36 | playlist.disabled = true;
|
37 | }
|
38 |
|
39 | if (enable !== currentlyEnabled && !incompatible) {
|
40 |
|
41 | changePlaylistFn();
|
42 | if (enable) {
|
43 | loader.trigger('renditionenabled');
|
44 | } else {
|
45 | loader.trigger('renditiondisabled');
|
46 | }
|
47 | }
|
48 | return enable;
|
49 | };
|
50 | };
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 | var Representation = function Representation(hlsHandler, playlist, id) {
|
61 | _classCallCheck(this, Representation);
|
62 |
|
63 |
|
64 | var fastChangeFunction = hlsHandler.masterPlaylistController_.fastQualityChange_.bind(hlsHandler.masterPlaylistController_);
|
65 |
|
66 |
|
67 | if (playlist.attributes.RESOLUTION) {
|
68 | var resolution = playlist.attributes.RESOLUTION;
|
69 |
|
70 | this.width = resolution.width;
|
71 | this.height = resolution.height;
|
72 | }
|
73 |
|
74 | this.bandwidth = playlist.attributes.BANDWIDTH;
|
75 |
|
76 |
|
77 |
|
78 | this.id = id;
|
79 |
|
80 |
|
81 |
|
82 | this.enabled = enableFunction(hlsHandler.playlists, playlist.uri, fastChangeFunction);
|
83 | }
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 | ;
|
92 |
|
93 | var renditionSelectionMixin = function renditionSelectionMixin(hlsHandler) {
|
94 | var playlists = hlsHandler.playlists;
|
95 |
|
96 |
|
97 | hlsHandler.representations = function () {
|
98 | return playlists.master.playlists.filter(function (media) {
|
99 | return !(0, _playlistJs.isIncompatible)(media);
|
100 | }).map(function (e, i) {
|
101 | return new Representation(hlsHandler, e, e.uri);
|
102 | });
|
103 | };
|
104 | };
|
105 |
|
106 | exports['default'] = renditionSelectionMixin;
|
107 | module.exports = exports['default']; |
\ | No newline at end of file |