diff --git src flash com longtailvideo jwplayer player IPlayer as src

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
diff --git a/src/flash/com/longtailvideo/jwplayer/player/IPlayer.as b/src/flash/com/longtailvideo/jwplayer/player/IPlayer.as
index 4988846..e116bf5 100644
--- a/src/flash/com/longtailvideo/jwplayer/player/IPlayer.as
+++ b/src/flash/com/longtailvideo/jwplayer/player/IPlayer.as
@@ -78,6 +78,7 @@ package com.longtailvideo.jwplayer.player {
function getQualityLevels():Array;
function getCurrentQuality():Number;
function setCurrentQuality(index:Number):void;
+ function setLevelVisibly(index:Number, flag:Boolean):void;
function getCaptionsList():Array;
function getCurrentCaptions():Number;
function setCurrentCaptions(index:Number):void;
@@ -91,4 +92,4 @@ package com.longtailvideo.jwplayer.player {
function get edition():String;
}
-}
\ No newline at end of file
+}
diff --git a/src/flash/com/longtailvideo/jwplayer/player/InstreamPlayer.as b/src/flash/com/longtailvideo/jwplayer/player/InstreamPlayer.as
index 832203a..0f8496d 100644
--- a/src/flash/com/longtailvideo/jwplayer/player/InstreamPlayer.as
+++ b/src/flash/com/longtailvideo/jwplayer/player/InstreamPlayer.as
@@ -691,6 +691,10 @@ package com.longtailvideo.jwplayer.player
throw new Error(UNSUPPORTED_ERROR);
}
+ public function setLevelVisibly(index:Number, flag:Boolean):void {
+ throw new Error(UNSUPPORTED_ERROR);
+ }
+
public function getAudioTracks():Array {
throw new Error(UNSUPPORTED_ERROR);
}
@@ -730,4 +734,4 @@ package com.longtailvideo.jwplayer.player
}
}
-}
\ No newline at end of file
+}
diff --git a/src/flash/com/longtailvideo/jwplayer/player/JavascriptAPI.as b/src/flash/com/longtailvideo/jwplayer/player/JavascriptAPI.as
index 70fd9ef..df1c9ef 100644
--- a/src/flash/com/longtailvideo/jwplayer/player/JavascriptAPI.as
+++ b/src/flash/com/longtailvideo/jwplayer/player/JavascriptAPI.as
@@ -222,6 +222,7 @@ package com.longtailvideo.jwplayer.player {
// Quality API
ExternalInterface.addCallback("jwGetQualityLevels", js_getQualityLevels);
+ ExternalInterface.addCallback("jwSetLevelVisibly", js_setLevelVisibly);
ExternalInterface.addCallback("jwGetCurrentQuality", js_getCurrentQuality);
ExternalInterface.addCallback("jwSetCurrentQuality", js_setCurrentQuality);
@@ -637,6 +638,10 @@ package com.longtailvideo.jwplayer.player {
return _player.getQualityLevels();
}
+ private static function js_setLevelVisibly(index:Number, flag:Boolean):void {
+ return _player.setLevelVisibly(index, flag);
+ }
+
private static function js_getCurrentQuality():Number {
return _player.getCurrentQuality();
}
diff --git a/src/flash/com/longtailvideo/jwplayer/player/Player.as b/src/flash/com/longtailvideo/jwplayer/player/Player.as
index 37399ff..610e030 100644
--- a/src/flash/com/longtailvideo/jwplayer/player/Player.as
+++ b/src/flash/com/longtailvideo/jwplayer/player/Player.as
@@ -333,6 +333,10 @@
if (model.media) model.media.currentQuality = index;
}
+ public function setLevelVisibly(index:Number, flag:Boolean):void {
+ view.components.controlbar.showLevel(index, flag);
+ }
+
public function getCaptionsList():Array {
return view.components.captions.getCaptionsList();
}
@@ -428,4 +432,4 @@
view.setCues(cues);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/flash/com/longtailvideo/jwplayer/view/components/ControlbarComponent.as b/src/flash/com/longtailvideo/jwplayer/view/components/ControlbarComponent.as
index 4802b26..b26976f 100644
--- a/src/flash/com/longtailvideo/jwplayer/view/components/ControlbarComponent.as
+++ b/src/flash/com/longtailvideo/jwplayer/view/components/ControlbarComponent.as
@@ -677,7 +677,7 @@ package com.longtailvideo.jwplayer.view.components {
private function showHdOverlay(evt:MouseEvent):void {
if (_audioMode) return;
- if (_hdOverlay && _levels && _levels.length > 2) _hdOverlay.show();
+ if (_hdOverlay && _levels && (!player.config.levels_toggle || _levels.length > 2)) _hdOverlay.show();
hideCcOverlay();
hideVolumeOverlay();
hideTrackOverlay();
@@ -727,13 +727,28 @@ package com.longtailvideo.jwplayer.view.components {
private function levelsHandler(evt:MediaEvent):void {
_levels = evt.levels;
+ levelChanged(evt);
+ }
+
+ private function updateHDOverlay() {
if (_levels.length > 1) {
_hdOverlay.clearOptions();
- for (var i:Number=0; i < _levels.length; i++) {
- _hdOverlay.addOption(_levels[i].label, i);
+ for (var i:Number = 0, j:Number = 0; i < _levels.length; i++) {
+ if (!("visible" in _levels[i]) || _levels[i].visible || _currentQuality == i) {
+ _hdOverlay.addOption(_levels[i].label, i);
+ if (_currentQuality == i)
+ _hdOverlay.setActive(j);
+ ++j;
+ }
}
}
- levelChanged(evt);
+ }
+
+ public function showLevel(index:Number, flag:Boolean):void {
+ if (index >= 0 && index < _levels.length) {
+ _levels[index].visible = flag;
+ updateHDOverlay();
+ }
}
private function levelChanged(evt:MediaEvent):void {
@@ -741,12 +756,13 @@ package com.longtailvideo.jwplayer.view.components {
var button:ComponentButton = getButton("hd") as ComponentButton;
if (button) {
- button.setOutIcon(getSkinElement("hdButton" + (_levels.length == 2 && _currentQuality == 0 ? "Off" : "")));
+ if (!player.config.levels_toggle)
+ button.setOutIcon(getSkinElement("hdButton"));
+ else
+ button.setOutIcon(getSkinElement("hdButton" + (_levels.length == 2 && _currentQuality == 0 ? "Off" : "")));
}
- if (_levels.length > 1) {
- _hdOverlay.setActive(evt.currentQuality);
- }
+ updateHDOverlay();
updateControlbarState();
}
diff --git a/src/flash/com/longtailvideo/jwplayer/view/interfaces/IControlbarComponent.as b/src/flash/com/longtailvideo/jwplayer/view/interfaces/IControlbarComponent.as
index fcd158c..a7ed492 100644
--- a/src/flash/com/longtailvideo/jwplayer/view/interfaces/IControlbarComponent.as
+++ b/src/flash/com/longtailvideo/jwplayer/view/interfaces/IControlbarComponent.as
@@ -69,5 +69,6 @@ package com.longtailvideo.jwplayer.view.interfaces {
function setInstreamMode(mode:Boolean):void;
function setCues(cues:Array):void;
function hideOverlays():void;
+ function showLevel(index:Number, flag:Boolean):void;
}
-}
\ No newline at end of file
+}
diff --git a/src/js/api/jwplayer.api.js b/src/js/api/jwplayer.api.js
index dca6d32..f2c484e 100644
--- a/src/js/api/jwplayer.api.js
+++ b/src/js/api/jwplayer.api.js
@@ -30,6 +30,7 @@
'getSafeRegion',
'getPosition',
'getQualityLevels',
+ 'setLevelVisibly',
'getState',
'getVolume',
'getWidth',
diff --git a/src/js/embed/jwplayer.embed.config.js b/src/js/embed/jwplayer.embed.config.js
index d60efa4..25ab8f2 100644
--- a/src/js/embed/jwplayer.embed.config.js
+++ b/src/js/embed/jwplayer.embed.config.js
@@ -9,6 +9,7 @@
fallback: true, // enable download embedder
height: 270,
primary: 'html5',
+ levels_toggle: true, // enable levels toggle (if == 2)
width: 480,
base: config.base ? config.base : utils.getScriptPath('jwplayer.js'),
aspectratio: ''
diff --git a/src/js/html5/jwplayer.html5.controlbar.js b/src/js/html5/jwplayer.html5.controlbar.js
index 8fd9d1c..9eee9c3 100644
--- a/src/js/html5/jwplayer.html5.controlbar.js
+++ b/src/js/html5/jwplayer.html5.controlbar.js
@@ -379,29 +379,46 @@
function _qualityHandler(evt) {
_levels = evt.levels || [];
+ _qualityLevelChanged(evt);
+ }
+
+ function _qualityLevelChanged(evt) {
+ _currentQuality = Math.floor(evt.currentQuality);
+ if (_elements.hd) {
+ if (!_config.levels_toggle) {
+ _elements.hd.querySelector('button').className = '';
+ } else {
+ _elements.hd.querySelector('button').className =
+ (_levels.length === 2 && _currentQuality === 0) ? 'off' : '';
+ }
+ }
+ _updateHDOverlay();
+ }
+
+ function _updateHDOverlay() {
if (_hasHD()) {
_css.style(_elements.hd, NOT_HIDDEN);
_hdOverlay.clearOptions();
- for (var i = 0; i < _levels.length; i++) {
- _hdOverlay.addOption(_levels[i].label, i);
+ for (var i = 0, j = 0; i < _levels.length; i++) {
+ if (!("visible" in _levels[i]) || _levels[i].visible || i == _currentQuality) {
+ _hdOverlay.addOption(_levels[i].label, i);
+ if (i == _currentQuality)
+ _hdOverlay.setActive(j);
+ ++j;
+ }
}
- _qualityLevelChanged(evt);
} else {
_css.style(_elements.hd, HIDDEN);
}
_redraw();
- }
+ }
- function _qualityLevelChanged(evt) {
- _currentQuality = Math.floor(evt.currentQuality);
- if (_elements.hd) {
- _elements.hd.querySelector('button').className =
- (_levels.length === 2 && _currentQuality === 0) ? 'off' : '';
- }
- if (_hdOverlay && _currentQuality >= 0) {
- _hdOverlay.setActive(evt.currentQuality);
- }
- }
+ _this.showLevel = function (index, flag) {
+ if (index >= 0 && index < _levels.length) {
+ _levels[index].visible = flag;
+ _updateHDOverlay();
+ }
+ }
function _hasCaptions() {
return (!_instreamMode && _captions && _captions.length > 1 && _ccOverlay);
@@ -836,7 +853,7 @@
}
function _showHd() {
- if (_levels.length > 2) {
+ if (!_config.levels_toggle || _levels.length > 2) {
if (_hdTimer) {
clearTimeout(_hdTimer);
_hdTimer = undefined;
@@ -885,7 +902,7 @@
}
function _hd() {
- if (_levels.length !== 2) {
+ if (!_config.levels_toggle || _levels.length !== 2) {
return;
}
_switchLevel((_currentQuality + 1) % 2);
@@ -1487,7 +1504,7 @@
}
_this.sendEvent(events.JWPLAYER_USER_ACTION);
} else if (name === 'hd') {
- if (_levels.length === 2) {
+ if (_config.levels_toggle && _levels.length === 2) {
tapAction = _hd;
}
if (_hdTapTimer) {
diff --git a/src/js/html5/jwplayer.html5.controller.js b/src/js/html5/jwplayer.html5.controller.js
index 33429bf..639ebc9 100644
--- a/src/js/html5/jwplayer.html5.controller.js
+++ b/src/js/html5/jwplayer.html5.controller.js
@@ -263,6 +263,10 @@
return null;
}
+ function _setLevelVisibly(index, flag) {
+ _view.getControllbar().showLevel(index, flag);
+ }
+
function _setCurrentAudioTrack(index) {
_video().setCurrentAudioTrack(index);
}
@@ -357,6 +361,7 @@
this.setCurrentQuality = _waitForReady(_setCurrentQuality);
this.getCurrentQuality = _getCurrentQuality;
this.getQualityLevels = _getQualityLevels;
+ this.setLevelVisibly = _setLevelVisibly;
this.setCurrentAudioTrack = _setCurrentAudioTrack;
this.getCurrentAudioTrack = _getCurrentAudioTrack;
this.getAudioTracks = _getAudioTracks;
diff --git a/src/js/html5/jwplayer.html5.instream.js b/src/js/html5/jwplayer.html5.instream.js
index f8c9ae6..424d147 100644
--- a/src/js/html5/jwplayer.html5.instream.js
+++ b/src/js/html5/jwplayer.html5.instream.js
@@ -543,6 +543,7 @@
_this.removeEventListener(type, handler);
};
_this.jwSetCurrentQuality = function() {};
+ _this.jwSetLevelVisibly = function() {};
_this.jwGetQualityLevels = function() {
return [];
};
diff --git a/src/js/html5/jwplayer.html5.player.js b/src/js/html5/jwplayer.html5.player.js
index 45bd89b..6a065d2 100644
--- a/src/js/html5/jwplayer.html5.player.js
+++ b/src/js/html5/jwplayer.html5.player.js
@@ -122,6 +122,7 @@
_this.jwGetQualityLevels = _controller.getQualityLevels;
_this.jwGetCurrentQuality = _controller.getCurrentQuality;
_this.jwSetCurrentQuality = _controller.setCurrentQuality;
+ _this.jwSetLevelVisibly = _controller.setLevelVisibly;
_this.jwGetAudioTracks = _controller.getAudioTracks;
_this.jwGetCurrentAudioTrack = _controller.getCurrentAudioTrack;
_this.jwSetCurrentAudioTrack = _controller.setCurrentAudioTrack;
diff --git a/src/js/html5/jwplayer.html5.view.js b/src/js/html5/jwplayer.html5.view.js
index 9e8bb4a..5b288a9 100644
--- a/src/js/html5/jwplayer.html5.view.js
+++ b/src/js/html5/jwplayer.html5.view.js
@@ -1335,6 +1335,10 @@
this.destroyInstream();
}
};
+
+ this.getControllbar = function () {
+ return _controlbar;
+ };
_init();
};