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 |
|
24 | var enableFunction = function enableFunction(loader, playlistUri, changePlaylistFn, enable) {
|
25 | var playlist = loader.master.playlists[playlistUri];
|
26 | var blacklisted = (0, _playlistJs.isBlacklisted)(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 && !blacklisted) {
|
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 | var Representation = function Representation(hlsHandler, playlist, id) {
|
60 | _classCallCheck(this, Representation);
|
61 |
|
62 |
|
63 | var fastChangeFunction = hlsHandler.masterPlaylistController_.fastQualityChange_.bind(hlsHandler.masterPlaylistController_);
|
64 |
|
65 |
|
66 |
|
67 | if (playlist.attributes) {
|
68 | var attributes = playlist.attributes;
|
69 |
|
70 | if (attributes.RESOLUTION) {
|
71 | var resolution = attributes.RESOLUTION;
|
72 |
|
73 | this.width = resolution.width;
|
74 | this.height = resolution.height;
|
75 | }
|
76 |
|
77 | this.bandwidth = attributes.BANDWIDTH;
|
78 | }
|
79 |
|
80 |
|
81 |
|
82 | this.id = id;
|
83 |
|
84 |
|
85 |
|
86 | this.enabled = enableFunction.bind(this, hlsHandler.playlists, playlist.uri, fastChangeFunction);
|
87 | }
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 | ;
|
96 |
|
97 | var renditionSelectionMixin = function renditionSelectionMixin(hlsHandler) {
|
98 | var playlists = hlsHandler.playlists;
|
99 |
|
100 |
|
101 | hlsHandler.representations = function () {
|
102 | return playlists.master.playlists.filter(function (media) {
|
103 | return !(0, _playlistJs.isBlacklisted)(media);
|
104 | }).map(function (e, i) {
|
105 | return new Representation(hlsHandler, e, e.uri);
|
106 | });
|
107 | };
|
108 | };
|
109 |
|
110 | exports['default'] = renditionSelectionMixin;
|
111 | module.exports = exports['default']; |
\ | No newline at end of file |