ovenplayer 0.10.39 → 0.10.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/ovenplayer.js +1 -1
- package/dist/ovenplayer.js.map +1 -1
- package/package.json +1 -1
- package/src/js/api/Configurator.js +4 -2
- package/src/js/api/constants.js +9 -0
- package/src/js/api/provider/html5/Listener.js +32 -33
- package/src/js/api/provider/html5/providers/WebRTC.js +9 -2
- package/src/js/utils/deepMerge.js +42 -0
- package/src/js/view/components/controls/progressBar.js +0 -22
- package/src/js/view/components/controls/settingPanel/main.js +4 -3
- package/src/js/view/components/controls/settingPanel/qualityPanel.js +1 -1
- package/src/js/view/components/controls/timeDisplay.js +14 -23
- package/src/js/view/view.js +101 -98
package/src/js/view/view.js
CHANGED
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
|
|
31
31
|
import '../../stylesheet/ovenplayer.less';
|
|
32
32
|
|
|
33
|
-
const View = function($container){
|
|
33
|
+
const View = function ($container) {
|
|
34
34
|
let viewTemplate = "", controls = "", helper = "", $playerRoot, contextPanel = "", api = null, autoHideTimer = "", playerState = STATE_IDLE;
|
|
35
35
|
let isShiftPressed = false;
|
|
36
36
|
let panelManager = PanelManager();
|
|
@@ -48,7 +48,7 @@ const View = function($container){
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
if (hide) {
|
|
51
|
-
if(panelManager.size() > 0){
|
|
51
|
+
if (panelManager.size() > 0) {
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
54
54
|
$playerRoot.addClass("op-autohide");
|
|
@@ -56,8 +56,8 @@ const View = function($container){
|
|
|
56
56
|
$playerRoot.removeClass("op-autohide");
|
|
57
57
|
|
|
58
58
|
if (autoHide) {
|
|
59
|
-
autoHideTimer = setTimeout(function() {
|
|
60
|
-
if(panelManager.size()> 0){
|
|
59
|
+
autoHideTimer = setTimeout(function () {
|
|
60
|
+
if (panelManager.size() > 0) {
|
|
61
61
|
return false;
|
|
62
62
|
}
|
|
63
63
|
$playerRoot.addClass("op-autohide");
|
|
@@ -75,7 +75,7 @@ const View = function($container){
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
api.play();
|
|
78
|
-
}else if(currentState === STATE_PLAYING){
|
|
78
|
+
} else if (currentState === STATE_PLAYING) {
|
|
79
79
|
api.pause();
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -85,35 +85,35 @@ const View = function($container){
|
|
|
85
85
|
const currentPosition = api.getPosition();
|
|
86
86
|
let position = 0;
|
|
87
87
|
|
|
88
|
-
if(isRewind){
|
|
88
|
+
if (isRewind) {
|
|
89
89
|
position = Math.max(currentPosition - seconds, 0);
|
|
90
|
-
}else{
|
|
90
|
+
} else {
|
|
91
91
|
position = Math.min(currentPosition + seconds, duration);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
api.seek(position);
|
|
95
95
|
}
|
|
96
|
-
function volume(isUp){
|
|
96
|
+
function volume(isUp) {
|
|
97
97
|
const currentVolumn = api.getVolume();
|
|
98
98
|
let newVolume = 0;
|
|
99
|
-
if(isUp){
|
|
100
|
-
newVolume =
|
|
101
|
-
}else{
|
|
99
|
+
if (isUp) {
|
|
100
|
+
newVolume = Math.min(currentVolumn + 5, 100);
|
|
101
|
+
} else {
|
|
102
102
|
newVolume = Math.max(currentVolumn - 5, 0);
|
|
103
103
|
}
|
|
104
104
|
api.setVolume(newVolume);
|
|
105
105
|
}
|
|
106
|
-
function createContextPanel(pageX, pageY){
|
|
107
|
-
if(contextPanel){
|
|
106
|
+
function createContextPanel(pageX, pageY) {
|
|
107
|
+
if (contextPanel) {
|
|
108
108
|
contextPanel.destroy();
|
|
109
109
|
contextPanel = null;
|
|
110
110
|
}
|
|
111
|
-
contextPanel = ContextPanel($playerRoot, api, {pageX
|
|
111
|
+
contextPanel = ContextPanel($playerRoot, api, { pageX: pageX, pageY: pageY });
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
function calcPlayerWidth(){
|
|
114
|
+
function calcPlayerWidth() {
|
|
115
115
|
let playerWidth = $playerRoot.width();
|
|
116
|
-
if(playerWidth < 576){
|
|
116
|
+
if (playerWidth < 576) {
|
|
117
117
|
screenSize = "xsmall";
|
|
118
118
|
$playerRoot.addClass("xsmall");
|
|
119
119
|
|
|
@@ -121,24 +121,24 @@ const View = function($container){
|
|
|
121
121
|
$playerRoot.addClass("xxsmall");
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
}else if(playerWidth < 768){
|
|
124
|
+
} else if (playerWidth < 768) {
|
|
125
125
|
screenSize = "small";
|
|
126
126
|
$playerRoot.addClass("small");
|
|
127
|
-
}else if(playerWidth < 992){
|
|
127
|
+
} else if (playerWidth < 992) {
|
|
128
128
|
screenSize = "medium";
|
|
129
129
|
$playerRoot.addClass("medium");
|
|
130
|
-
}else{
|
|
130
|
+
} else {
|
|
131
131
|
screenSize = "large";
|
|
132
132
|
$playerRoot.addClass("large");
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
const onRendered = function($current, template){
|
|
136
|
+
const onRendered = function ($current, template) {
|
|
137
137
|
$playerRoot = $current;
|
|
138
138
|
viewTemplate = template;
|
|
139
139
|
calcPlayerWidth();
|
|
140
140
|
currentPlayerSize = screenSize;
|
|
141
|
-
resizeSensor = new ResizeSensor($playerRoot.get(), function() {
|
|
141
|
+
resizeSensor = new ResizeSensor($playerRoot.get(), function () {
|
|
142
142
|
|
|
143
143
|
$playerRoot.removeClass("large");
|
|
144
144
|
$playerRoot.removeClass("medium");
|
|
@@ -146,47 +146,47 @@ const View = function($container){
|
|
|
146
146
|
$playerRoot.removeClass("xsmall");
|
|
147
147
|
$playerRoot.removeClass("xxsmall");
|
|
148
148
|
calcPlayerWidth();
|
|
149
|
-
if(screenSize !== currentPlayerSize){
|
|
149
|
+
if (screenSize !== currentPlayerSize) {
|
|
150
150
|
currentPlayerSize = screenSize;
|
|
151
|
-
if(api){
|
|
151
|
+
if (api) {
|
|
152
152
|
api.trigger(PLAYER_RESIZED, currentPlayerSize);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
});
|
|
156
156
|
|
|
157
157
|
};
|
|
158
|
-
const onDestroyed = function(){
|
|
159
|
-
if(resizeSensor) {
|
|
158
|
+
const onDestroyed = function () {
|
|
159
|
+
if (resizeSensor) {
|
|
160
160
|
resizeSensor.detach();
|
|
161
161
|
resizeSensor = null;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
if(helper){
|
|
164
|
+
if (helper) {
|
|
165
165
|
helper.destroy();
|
|
166
166
|
helper = null;
|
|
167
167
|
}
|
|
168
|
-
if(controls){
|
|
168
|
+
if (controls) {
|
|
169
169
|
controls.destroy();
|
|
170
170
|
controls = null;
|
|
171
171
|
}
|
|
172
172
|
};
|
|
173
173
|
const events = {
|
|
174
|
-
"click .ovenplayer"
|
|
174
|
+
"click .ovenplayer": function (event, $current, template) {
|
|
175
175
|
|
|
176
|
-
if(api){
|
|
176
|
+
if (api) {
|
|
177
177
|
api.trigger(PLAYER_CLICKED, event);
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
if(contextPanel){
|
|
180
|
+
if (contextPanel) {
|
|
181
181
|
event.preventDefault();
|
|
182
182
|
contextPanel.destroy();
|
|
183
183
|
contextPanel = null;
|
|
184
184
|
return false;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
if(!(LA$(event.target).closest(".op-controls-container") || LA$(event.target).closest(".op-setting-panel")
|
|
187
|
+
if (!(LA$(event.target).closest(".op-controls-container") || LA$(event.target).closest(".op-setting-panel"))) {
|
|
188
188
|
|
|
189
|
-
if(panelManager.size() > 0){
|
|
189
|
+
if (panelManager.size() > 0) {
|
|
190
190
|
event.preventDefault();
|
|
191
191
|
panelManager.clear();
|
|
192
192
|
return false;
|
|
@@ -198,46 +198,46 @@ const View = function($container){
|
|
|
198
198
|
|
|
199
199
|
}
|
|
200
200
|
},
|
|
201
|
-
"dblclick .ovenplayer"
|
|
201
|
+
"dblclick .ovenplayer": function (event, $current, template) {
|
|
202
202
|
if (api) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
203
|
+
const touchPosition = getTouchSection(event);
|
|
204
|
+
const currentPosition = api.getPosition();
|
|
205
|
+
const tapToSeekEnabled = api.getConfig().doubleTapToSeek;
|
|
206
|
+
|
|
207
|
+
// seek back 10s
|
|
208
|
+
if (tapToSeekEnabled && touchPosition == 'left') {
|
|
209
|
+
const newPosition = Math.max(currentPosition - 10, 0);
|
|
210
|
+
OvenPlayerConsole.log(`Seeking to ${newPosition}`);
|
|
211
|
+
api.seek(newPosition);
|
|
212
|
+
}
|
|
213
213
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
214
|
+
// seek forward 10s
|
|
215
|
+
if (tapToSeekEnabled && touchPosition === 'right') {
|
|
216
|
+
const newPosition = Math.min(currentPosition + 10, api.getDuration());
|
|
217
|
+
OvenPlayerConsole.log(`Seeking to ${newPosition}`);
|
|
218
|
+
api.seek(newPosition);
|
|
219
|
+
}
|
|
220
220
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
if (touchPosition === 'middle' || !tapToSeekEnabled) {
|
|
222
|
+
OvenPlayerConsole.log(`Toggling fullscreen`);
|
|
223
|
+
if (api.getConfig().expandFullScreenUI && api.toggleFullScreen) {
|
|
224
224
|
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
if (!(LA$(event.target).closest(".op-controls-container") || LA$(event.target).closest(".op-setting-panel"))) {
|
|
226
|
+
api.toggleFullScreen();
|
|
227
|
+
}
|
|
227
228
|
}
|
|
228
229
|
}
|
|
229
230
|
}
|
|
230
|
-
}
|
|
231
231
|
},
|
|
232
232
|
//For iOS safari
|
|
233
|
-
"touchstart .ovenplayer"
|
|
234
|
-
if (playerState === STATE_PLAYING || playerState === STATE_IDLE
|
|
233
|
+
"touchstart .ovenplayer": function (event, $current, template) {
|
|
234
|
+
if (playerState === STATE_PLAYING || playerState === STATE_IDLE || playerState === STATE_LOADING || (playerState === STATE_AD_PLAYING && screenSize === "xsmall")) {
|
|
235
235
|
setHide(false, true);
|
|
236
236
|
} else {
|
|
237
237
|
setHide(false);
|
|
238
238
|
}
|
|
239
239
|
},
|
|
240
|
-
"mouseenter .ovenplayer"
|
|
240
|
+
"mouseenter .ovenplayer": function (event, $current, template) {
|
|
241
241
|
event.preventDefault();
|
|
242
242
|
|
|
243
243
|
//small screen with STATE_AD_PLAYING setHide too. becuase mobile hide ad ui.
|
|
@@ -247,7 +247,7 @@ const View = function($container){
|
|
|
247
247
|
setHide(false);
|
|
248
248
|
}
|
|
249
249
|
},
|
|
250
|
-
"mousemove .ovenplayer"
|
|
250
|
+
"mousemove .ovenplayer": function (event, $current, template) {
|
|
251
251
|
event.preventDefault();
|
|
252
252
|
|
|
253
253
|
if (playerState === STATE_PLAYING || playerState === STATE_IDLE || playerState === STATE_LOADING || (playerState === STATE_AD_PLAYING && screenSize === "xsmall")) {
|
|
@@ -256,71 +256,71 @@ const View = function($container){
|
|
|
256
256
|
setHide(false);
|
|
257
257
|
}
|
|
258
258
|
},
|
|
259
|
-
"mouseleave .ovenplayer"
|
|
259
|
+
"mouseleave .ovenplayer": function (event, $current, template) {
|
|
260
260
|
event.preventDefault();
|
|
261
261
|
|
|
262
|
-
if(playerState === STATE_PLAYING
|
|
262
|
+
if (playerState === STATE_PLAYING || playerState === STATE_IDLE || playerState === STATE_LOADING || (playerState === STATE_AD_PLAYING && screenSize === "xsmall")) {
|
|
263
263
|
setHide(true);
|
|
264
264
|
}
|
|
265
265
|
},
|
|
266
|
-
"keydown .ovenplayer"
|
|
266
|
+
"keydown .ovenplayer": function (event, $current, template) {
|
|
267
267
|
let frameMode = api.getFramerate();
|
|
268
|
-
switch(event.keyCode){
|
|
269
|
-
case 16
|
|
268
|
+
switch (event.keyCode) {
|
|
269
|
+
case 16: //shift
|
|
270
270
|
event.preventDefault();
|
|
271
271
|
isShiftPressed = true;
|
|
272
272
|
break;
|
|
273
|
-
case 32
|
|
273
|
+
case 32: //space
|
|
274
274
|
event.preventDefault();
|
|
275
275
|
togglePlayPause();
|
|
276
276
|
break;
|
|
277
|
-
case 37
|
|
277
|
+
case 37: //arrow left
|
|
278
278
|
event.preventDefault();
|
|
279
279
|
|
|
280
280
|
if (!api.getConfig().disableSeekUI) {
|
|
281
|
-
if(isShiftPressed && frameMode){
|
|
281
|
+
if (isShiftPressed && frameMode) {
|
|
282
282
|
api.seekFrame(-1);
|
|
283
|
-
}else{
|
|
283
|
+
} else {
|
|
284
284
|
seek(5, true);
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
break;
|
|
288
|
-
case 39
|
|
288
|
+
case 39: //arrow right
|
|
289
289
|
event.preventDefault();
|
|
290
290
|
|
|
291
291
|
if (!api.getConfig().disableSeekUI) {
|
|
292
292
|
|
|
293
|
-
if(isShiftPressed && frameMode){
|
|
293
|
+
if (isShiftPressed && frameMode) {
|
|
294
294
|
api.seekFrame(1);
|
|
295
|
-
}else{
|
|
295
|
+
} else {
|
|
296
296
|
seek(5, false);
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
break;
|
|
301
|
-
case 38
|
|
301
|
+
case 38: //arrow up
|
|
302
302
|
event.preventDefault();
|
|
303
303
|
volume(true);
|
|
304
304
|
break;
|
|
305
|
-
case 40
|
|
305
|
+
case 40: //arrow up
|
|
306
306
|
event.preventDefault();
|
|
307
307
|
volume(false);
|
|
308
308
|
break;
|
|
309
309
|
}
|
|
310
310
|
|
|
311
311
|
},
|
|
312
|
-
"keyup .ovenplayer"
|
|
313
|
-
switch(event.keyCode) {
|
|
314
|
-
case 16
|
|
312
|
+
"keyup .ovenplayer": function (event, $current, template) {
|
|
313
|
+
switch (event.keyCode) {
|
|
314
|
+
case 16: //shift
|
|
315
315
|
event.preventDefault();
|
|
316
316
|
isShiftPressed = false;
|
|
317
317
|
break;
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
},
|
|
321
|
-
"contextmenu .ovenplayer"
|
|
321
|
+
"contextmenu .ovenplayer": function (event, $current, template) {
|
|
322
322
|
event.stopPropagation();
|
|
323
|
-
if(!LA$(event.currentTarget).find("object")){
|
|
323
|
+
if (!LA$(event.currentTarget).find("object")) {
|
|
324
324
|
event.preventDefault();
|
|
325
325
|
createContextPanel(event.pageX, event.pageY);
|
|
326
326
|
return false;
|
|
@@ -345,9 +345,9 @@ const View = function($container){
|
|
|
345
345
|
return $playerRoot.get().id;
|
|
346
346
|
};
|
|
347
347
|
|
|
348
|
-
api.on(READY, function(data) {
|
|
348
|
+
api.on(READY, function (data) {
|
|
349
349
|
|
|
350
|
-
if(!controls){
|
|
350
|
+
if (!controls) {
|
|
351
351
|
controls = Controls($playerRoot.find(".op-ui"), playerInstance);
|
|
352
352
|
}
|
|
353
353
|
|
|
@@ -355,12 +355,13 @@ const View = function($container){
|
|
|
355
355
|
$playerRoot.addClass("op-no-controls");
|
|
356
356
|
}
|
|
357
357
|
|
|
358
|
+
setHide(false, true);
|
|
358
359
|
});
|
|
359
360
|
|
|
360
|
-
api.on(ERROR, function(error) {
|
|
361
|
-
if(api){
|
|
362
|
-
let sources = api.getSources()||[];
|
|
363
|
-
if(controls && (sources.length <= 1)){
|
|
361
|
+
api.on(ERROR, function (error) {
|
|
362
|
+
if (api) {
|
|
363
|
+
let sources = api.getSources() || [];
|
|
364
|
+
if (controls && (sources.length <= 1)) {
|
|
364
365
|
// controls.destroy();
|
|
365
366
|
// controls = null;
|
|
366
367
|
}
|
|
@@ -368,26 +369,27 @@ const View = function($container){
|
|
|
368
369
|
|
|
369
370
|
});
|
|
370
371
|
|
|
371
|
-
api.on(DESTROY, function(data) {
|
|
372
|
+
api.on(DESTROY, function (data) {
|
|
372
373
|
viewTemplate.destroy();
|
|
373
374
|
});
|
|
374
375
|
|
|
375
376
|
api.on(PLAYER_PLAY, function (data) {
|
|
376
|
-
if(!controls && showControlBar){
|
|
377
|
+
if (!controls && showControlBar) {
|
|
377
378
|
controls = Controls($playerRoot.find(".op-ui"), playerInstance);
|
|
378
379
|
}
|
|
379
380
|
});
|
|
380
381
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
}
|
|
382
|
+
// Don't need to setHide on each state change
|
|
383
|
+
// api.on(PLAYER_STATE, function(data){
|
|
384
|
+
// if(data && data.newstate){
|
|
385
|
+
// playerState = data.newstate;
|
|
386
|
+
// if(data.newstate === STATE_PLAYING || (data.newstate === STATE_AD_PLAYING && screenSize === "xsmall")){
|
|
387
|
+
// setHide(false, true);
|
|
388
|
+
// }else{
|
|
389
|
+
// setHide(false);
|
|
390
|
+
// }
|
|
391
|
+
// }
|
|
392
|
+
// });
|
|
391
393
|
|
|
392
394
|
let showControlBar = api.getConfig() && api.getConfig().controls;
|
|
393
395
|
|
|
@@ -409,10 +411,11 @@ const View = function($container){
|
|
|
409
411
|
}
|
|
410
412
|
}
|
|
411
413
|
|
|
412
|
-
api.showControls = function (show) {
|
|
414
|
+
api.showControls = function (show, keepOpen) {
|
|
413
415
|
if (show) {
|
|
414
416
|
$playerRoot.removeClass("op-no-controls");
|
|
415
|
-
|
|
417
|
+
let autoHide = !keepOpen
|
|
418
|
+
setHide(false, autoHide);
|
|
416
419
|
} else {
|
|
417
420
|
$playerRoot.addClass("op-no-controls");
|
|
418
421
|
}
|