ovenplayer 0.10.2 → 0.10.3-3.alpha-2

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.
Files changed (49) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +39 -46
  3. package/dist/ovenplayer.js +1 -1
  4. package/dist/ovenplayer.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/assets/fonts/seek-icons.svg +13 -13
  7. package/src/js/api/Api.js +231 -140
  8. package/src/js/api/Configurator.js +6 -3
  9. package/src/js/api/SupportChecker.js +9 -3
  10. package/src/js/api/constants.js +203 -15
  11. package/src/js/api/media/Manager.js +15 -106
  12. package/src/js/api/provider/Controller.js +5 -6
  13. package/src/js/api/provider/html5/Provider.js +107 -86
  14. package/src/js/api/provider/html5/providers/Dash.js +39 -110
  15. package/src/js/api/provider/html5/providers/Hls.js +139 -99
  16. package/src/js/api/provider/html5/providers/Html5.js +3 -1
  17. package/src/js/api/provider/html5/providers/WebRTC.js +207 -37
  18. package/src/js/api/provider/html5/providers/WebRTCLoader.js +247 -116
  19. package/src/js/ovenplayer.js +5 -9
  20. package/src/js/ovenplayer.sdk.js +5 -6
  21. package/src/js/utils/browser.js +6 -1
  22. package/src/js/utils/getTouchSection.js +23 -0
  23. package/src/js/utils/likeA$.js +4 -3
  24. package/src/js/utils/resize-sensor.js +168 -1
  25. package/src/js/utils/underscore.js +5 -5
  26. package/src/js/view/components/controls/fullScreenButton.js +22 -15
  27. package/src/js/view/components/controls/main.js +33 -20
  28. package/src/js/view/components/controls/playlistPanel.js +1 -1
  29. package/src/js/view/components/controls/progressBar.js +151 -76
  30. package/src/js/view/components/controls/settingButton.js +65 -48
  31. package/src/js/view/components/controls/settingPanel/audioTrackPanel.js +57 -0
  32. package/src/js/view/components/controls/settingPanel/captionPanel.js +1 -1
  33. package/src/js/view/components/controls/settingPanel/main.js +110 -80
  34. package/src/js/view/components/controls/settingPanel/qualityPanel.js +2 -2
  35. package/src/js/view/components/controls/settingPanel/sourcePanel.js +1 -1
  36. package/src/js/view/components/controls/settingPanel/speedPanel.js +1 -1
  37. package/src/js/view/components/controls/settingPanel/timeDisplayPanel.js +1 -1
  38. package/src/js/view/components/controls/timeDisplay.js +95 -23
  39. package/src/js/view/components/controls/timeDisplayTemplate.js +1 -1
  40. package/src/js/view/components/controls/volumeButton.js +2 -3
  41. package/src/js/view/components/helpers/captionViewer.js +1 -1
  42. package/src/js/view/components/helpers/contextPanel.js +1 -1
  43. package/src/js/view/components/helpers/contextPanelTemplate.js +1 -1
  44. package/src/js/view/components/helpers/main.js +21 -0
  45. package/src/js/view/components/helpers/thumbnailTemplate.js +0 -1
  46. package/src/js/view/engine/Templates.js +2 -0
  47. package/src/js/view/view.js +53 -14
  48. package/src/js/view/viewTemplate.js +8 -8
  49. package/src/stylesheet/ovenplayer.less +565 -308
@@ -5,17 +5,16 @@ import Ima from "api/ads/ima/Ad";
5
5
  import Vast from "api/ads/vast/Ad";
6
6
  import EventEmitter from "api/EventEmitter";
7
7
  import EventsListener from "api/provider/html5/Listener";
8
- import {extractVideoElement, pickCurrentSource} from "api/provider/utils";
8
+ import { pickCurrentSource } from "api/provider/utils";
9
9
  import {
10
10
  WARN_MSG_MUTEDPLAY,
11
11
  UI_ICONS, PLAYER_WARNING,
12
12
  STATE_IDLE, STATE_PLAYING, STATE_PAUSED, STATE_COMPLETE, STATE_ERROR,
13
13
  PLAYER_STATE, PLAYER_COMPLETE, PLAYER_PAUSE, PLAYER_PLAY, STATE_AD_PLAYING, STATE_AD_PAUSED,
14
- CONTENT_TIME, CONTENT_CAPTION_CUE_CHANGED, CONTENT_SOURCE_CHANGED,
14
+ CONTENT_META, CONTENT_TIME, CONTENT_CAPTION_CUE_CHANGED, CONTENT_SOURCE_CHANGED,
15
15
  AD_CLIENT_GOOGLEIMA, AD_CLIENT_VAST,
16
16
  PLAYBACK_RATE_CHANGED, CONTENT_MUTE, PROVIDER_HTML5, PROVIDER_WEBRTC, PROVIDER_DASH, PROVIDER_HLS
17
17
  } from "api/constants";
18
- import {CONTENT_META} from "../../constants";
19
18
 
20
19
  /**
21
20
  * @brief Core For Html5 Video.
@@ -23,10 +22,10 @@ import {CONTENT_META} from "../../constants";
23
22
  * @param playerConfig player config
24
23
  * @param onExtendedLoad on load handler
25
24
  * */
26
- const Provider = function (spec, playerConfig, onExtendedLoad){
25
+ const Provider = function (spec, playerConfig, onExtendedLoad) {
27
26
  OvenPlayerConsole.log("[Provider] loaded. ");
28
27
 
29
- let that ={};
28
+ let that = {};
30
29
  EventEmitter(that);
31
30
 
32
31
  let dashAttachedView = false;
@@ -36,15 +35,15 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
36
35
 
37
36
  let isPlayingProcessing = false;
38
37
 
39
- if(spec.adTagUrl){
38
+ if (spec.adTagUrl) {
40
39
  OvenPlayerConsole.log("[Provider] Ad Client - ", playerConfig.getAdClient());
41
- if(playerConfig.getAdClient() === AD_CLIENT_VAST){
40
+ if (playerConfig.getAdClient() === AD_CLIENT_VAST) {
42
41
  ads = Vast(elVideo, that, playerConfig, spec.adTagUrl);
43
- }else{
42
+ } else {
44
43
  ads = Ima(elVideo, that, playerConfig, spec.adTagUrl);
45
44
  }
46
45
 
47
- if(!ads){
46
+ if (!ads) {
48
47
  console.log("Can not load due to google ima for Ads.");
49
48
  }
50
49
  }
@@ -52,23 +51,23 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
52
51
  listener = EventsListener(elVideo, that, ads ? ads.videoEndedCallback : null, playerConfig);
53
52
  elVideo.playbackRate = elVideo.defaultPlaybackRate = playerConfig.getPlaybackRate();
54
53
 
55
- const _load = (lastPlayPosition) =>{
54
+ const _load = (lastPlayPosition) => {
56
55
 
57
- const source = spec.sources[spec.currentSource];
56
+ const source = spec.sources[spec.currentSource];
58
57
  spec.framerate = source.framerate;
59
58
 
60
59
  that.setVolume(playerConfig.getVolume());
61
60
 
62
- if(!spec.framerate){
61
+ if (!spec.framerate) {
63
62
  //init timecode mode
64
63
  playerConfig.setTimecodeMode(true);
65
64
  }
66
- if(onExtendedLoad){
65
+ if (onExtendedLoad) {
67
66
  onExtendedLoad(source, lastPlayPosition);
68
67
 
69
- }else{
68
+ } else {
70
69
 
71
- OvenPlayerConsole.log("source loaded : ", source, "lastPlayPosition : "+ lastPlayPosition);
70
+ OvenPlayerConsole.log("source loaded : ", source, "lastPlayPosition : " + lastPlayPosition);
72
71
 
73
72
  let previousSource = elVideo.src;
74
73
 
@@ -107,16 +106,19 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
107
106
  that.getMse = () => {
108
107
  return spec.mse;
109
108
  };
109
+ that.getMediaElement = () => {
110
+ return spec.element;
111
+ };
110
112
  that.canSeek = () => {
111
113
  return spec.canSeek;
112
114
  };
113
115
  that.setCanSeek = (canSeek) => {
114
116
  spec.canSeek = canSeek;
115
117
  };
116
- that.isSeeking = ()=>{
118
+ that.isSeeking = () => {
117
119
  return spec.seeking;
118
120
  };
119
- that.setSeeking = (seeking)=>{
121
+ that.setSeeking = (seeking) => {
120
122
  spec.seeking = seeking;
121
123
  };
122
124
  that.setMetaLoaded = () => {
@@ -127,13 +129,13 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
127
129
  };
128
130
 
129
131
  that.setState = (newState) => {
130
- if(spec.state !== newState){
132
+ if (spec.state !== newState) {
131
133
  let prevState = spec.state;
132
134
 
133
135
  OvenPlayerConsole.log("Provider : setState()", newState);
134
136
 
135
137
  //ToDo : This is temporary code. If main video occur error, player avoid error message on ad playing.
136
- if(prevState === STATE_AD_PLAYING && (newState === STATE_ERROR || newState === STATE_IDLE) ){
138
+ if (prevState === STATE_AD_PLAYING && (newState === STATE_ERROR || newState === STATE_IDLE)) {
137
139
  return false;
138
140
  }
139
141
 
@@ -154,28 +156,28 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
154
156
 
155
157
  OvenPlayerConsole.log("Provider : triggerSatatus", newState);
156
158
  switch (newState) {
157
- case STATE_COMPLETE :
159
+ case STATE_COMPLETE:
158
160
  that.trigger(PLAYER_COMPLETE);
159
161
  break;
160
- case STATE_PAUSED :
162
+ case STATE_PAUSED:
161
163
  that.trigger(PLAYER_PAUSE, {
162
164
  prevState: spec.state,
163
165
  newstate: STATE_PAUSED
164
166
  });
165
167
  break;
166
- case STATE_AD_PAUSED :
168
+ case STATE_AD_PAUSED:
167
169
  that.trigger(PLAYER_PAUSE, {
168
170
  prevState: spec.state,
169
171
  newstate: STATE_AD_PAUSED
170
172
  });
171
173
  break;
172
- case STATE_PLAYING :
174
+ case STATE_PLAYING:
173
175
  that.trigger(PLAYER_PLAY, {
174
176
  prevState: spec.state,
175
177
  newstate: STATE_PLAYING
176
178
  });
177
179
  break;
178
- case STATE_AD_PLAYING :
180
+ case STATE_AD_PLAYING:
179
181
  that.trigger(PLAYER_PLAY, {
180
182
  prevState: spec.state,
181
183
  newstate: STATE_AD_PLAYING
@@ -191,8 +193,7 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
191
193
 
192
194
  }
193
195
  };
194
-
195
- that.getState = () =>{
196
+ that.getState = () => {
196
197
  return spec.state;
197
198
  };
198
199
  that.setBuffer = (newBuffer) => {
@@ -205,56 +206,60 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
205
206
  return spec.isLive ? true : (elVideo.duration === Infinity);
206
207
  };
207
208
  that.getDuration = () => {
208
- return that.isLive() ? Infinity : elVideo.duration;
209
+ return that.isLive() ? Infinity : elVideo.duration;
210
+ };
211
+ that.getDvrWindow = () => {
212
+ return spec.dvrWindow;
209
213
  };
210
214
  that.getPosition = () => {
211
- if(!elVideo){
215
+ if (!elVideo) {
212
216
  return 0;
213
217
  }
214
218
  return elVideo.currentTime;
215
219
  };
216
- that.setVolume = (volume) =>{
217
- if(!elVideo){
220
+ that.setVolume = (volume) => {
221
+ if (!elVideo) {
218
222
  return false;
219
223
  }
220
- elVideo.volume = volume/100;
224
+ elVideo.volume = volume / 100;
225
+ playerConfig.setVolume(volume);
221
226
  };
222
- that.getVolume = () =>{
223
- if(!elVideo){
224
- return 0;
225
- }
226
- return elVideo.volume*100;
227
+ that.getVolume = () => {
228
+
229
+ return playerConfig.getVolume();
227
230
  };
228
- that.setMute = (state) =>{
229
- if(!elVideo){
231
+ that.setMute = (state) => {
232
+ if (!elVideo) {
230
233
  return false;
231
234
  }
232
235
  if (typeof state === 'undefined') {
233
236
 
234
- elVideo.muted = !elVideo.muted;
237
+ const muted = playerConfig.isMute();
238
+
239
+ elVideo.muted = !muted;
240
+ playerConfig.setMute(!muted);
235
241
 
236
242
  that.trigger(CONTENT_MUTE, {
237
- mute: elVideo.muted
243
+ mute: playerConfig.isMute()
238
244
  });
239
245
 
240
246
  } else {
241
247
 
242
248
  elVideo.muted = state;
249
+ playerConfig.setMute(state);
243
250
 
244
251
  that.trigger(CONTENT_MUTE, {
245
- mute: elVideo.muted
252
+ mute: playerConfig.isMute()
246
253
  });
247
254
  }
248
255
  return elVideo.muted;
249
256
  };
250
- that.getMute = () =>{
251
- if(!elVideo){
252
- return false;
253
- }
254
- return elVideo.muted;
257
+ that.getMute = () => {
258
+
259
+ return playerConfig.isMute();
255
260
  };
256
261
 
257
- that.preload = (sources, lastPlayPosition) =>{
262
+ that.preload = (sources, lastPlayPosition) => {
258
263
 
259
264
  spec.sources = sources;
260
265
 
@@ -263,10 +268,10 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
263
268
 
264
269
  return new Promise(function (resolve, reject) {
265
270
 
266
- if(playerConfig.isMute()){
271
+ if (playerConfig.isMute()) {
267
272
  that.setMute(true);
268
273
  }
269
- if(playerConfig.getVolume()){
274
+ if (playerConfig.getVolume()) {
270
275
  that.setVolume(playerConfig.getVolume());
271
276
  }
272
277
 
@@ -274,17 +279,17 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
274
279
  });
275
280
 
276
281
  };
277
- that.load = (sources) =>{
282
+ that.load = (sources) => {
278
283
 
279
284
  spec.sources = sources;
280
285
  spec.currentSource = pickCurrentSource(sources, playerConfig);
281
286
  _load(0);
282
287
  };
283
288
 
284
- that.play = () =>{
289
+ that.play = () => {
285
290
 
286
291
  OvenPlayerConsole.log("Provider : play()");
287
- if(!elVideo){
292
+ if (!elVideo) {
288
293
  return false;
289
294
  }
290
295
 
@@ -294,8 +299,8 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
294
299
  // }
295
300
 
296
301
  isPlayingProcessing = true;
297
- if(that.getState() !== STATE_PLAYING){
298
- if ( (ads && ads.isActive()) || (ads && !ads.started()) ) {
302
+ if (that.getState() !== STATE_PLAYING) {
303
+ if ((ads && ads.isActive()) || (ads && !ads.started())) {
299
304
  ads.play().then(_ => {
300
305
  //ads play success
301
306
  isPlayingProcessing = false;
@@ -307,10 +312,10 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
307
312
  OvenPlayerConsole.log("Provider : ads play fail", error);
308
313
  });
309
314
 
310
- }else{
315
+ } else {
311
316
  let promise = elVideo.play();
312
317
  if (promise !== undefined) {
313
- promise.then(function(){
318
+ promise.then(function () {
314
319
  isPlayingProcessing = false;
315
320
  OvenPlayerConsole.log("Provider : video play success");
316
321
  /*
@@ -335,7 +340,7 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
335
340
  }
336
341
  */
337
342
  });
338
- }else{
343
+ } else {
339
344
  //IE promise is undefinded.
340
345
  OvenPlayerConsole.log("Provider : video play success (ie)");
341
346
  isPlayingProcessing = false;
@@ -344,51 +349,51 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
344
349
  }
345
350
 
346
351
  };
347
- that.pause = () =>{
352
+ that.pause = () => {
348
353
 
349
354
  OvenPlayerConsole.log("Provider : pause()");
350
- if(!elVideo){
355
+ if (!elVideo) {
351
356
  return false;
352
357
  }
353
358
 
354
359
  if (that.getState() === STATE_PLAYING) {
355
360
  elVideo.pause();
356
- }else if(that.getState() === STATE_AD_PLAYING){
361
+ } else if (that.getState() === STATE_AD_PLAYING) {
357
362
  ads.pause();
358
363
  }
359
364
  };
360
- that.seek = (position) =>{
361
- if(!elVideo){
365
+ that.seek = (position) => {
366
+ if (!elVideo) {
362
367
  return false;
363
368
  }
364
369
  elVideo.currentTime = position;
365
370
  };
366
- that.setPlaybackRate = (playbackRate) =>{
367
- if(!elVideo){
371
+ that.setPlaybackRate = (playbackRate) => {
372
+ if (!elVideo) {
368
373
  return false;
369
374
  }
370
- that.trigger(PLAYBACK_RATE_CHANGED, {playbackRate : playbackRate});
375
+ that.trigger(PLAYBACK_RATE_CHANGED, { playbackRate: playbackRate });
371
376
  return elVideo.playbackRate = elVideo.defaultPlaybackRate = playbackRate;
372
377
  };
373
- that.getPlaybackRate = () =>{
374
- if(!elVideo){
378
+ that.getPlaybackRate = () => {
379
+ if (!elVideo) {
375
380
  return 0;
376
381
  }
377
382
  return elVideo.playbackRate;
378
383
  };
379
384
 
380
385
  that.getSources = () => {
381
- if(!elVideo){
386
+ if (!elVideo) {
382
387
  return [];
383
388
  }
384
389
 
385
- return spec.sources.map(function(source, index) {
390
+ return spec.sources.map(function (source, index) {
386
391
 
387
392
  var obj = {
388
393
  file: source.file,
389
394
  type: source.type,
390
395
  label: source.label,
391
- index : index,
396
+ index: index,
392
397
  sectionStart: source.sectionStart,
393
398
  sectionEnd: source.sectionEnd,
394
399
  gridThumbnail: source.gridThumbnail,
@@ -401,27 +406,24 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
401
406
  return obj;
402
407
  });
403
408
  };
404
- that.getCurrentSource = () =>{
409
+ that.getCurrentSource = () => {
405
410
  return spec.currentSource;
406
411
  };
407
412
  that.setCurrentSource = (sourceIndex, needProviderChange) => {
408
413
 
409
- if(sourceIndex > -1){
410
- if(spec.sources && spec.sources.length > sourceIndex){
414
+ if (sourceIndex > -1) {
415
+ if (spec.sources && spec.sources.length > sourceIndex) {
411
416
  //that.pause();
412
417
  //that.setState(STATE_IDLE);
413
418
  OvenPlayerConsole.log("source changed : " + sourceIndex);
414
419
  spec.currentSource = sourceIndex;
415
420
 
416
- that.trigger(CONTENT_SOURCE_CHANGED, {
417
- currentSource: sourceIndex
418
- });
419
421
  playerConfig.setSourceIndex(sourceIndex);
420
422
  //playerConfig.setSourceLabel(spec.sources[sourceIndex].label);
421
423
  //spec.currentQuality = sourceIndex;
422
424
  //that.pause();
423
425
  that.setState(STATE_IDLE);
424
- if(needProviderChange){
426
+ if (needProviderChange) {
425
427
  _load(elVideo.currentTime || 0);
426
428
  }
427
429
  //
@@ -432,13 +434,13 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
432
434
 
433
435
 
434
436
  that.getQualityLevels = () => {
435
- if(!elVideo){
437
+ if (!elVideo) {
436
438
  return [];
437
439
  }
438
440
  return spec.qualityLevels;
439
441
  };
440
442
  that.getCurrentQuality = () => {
441
- if(!elVideo){
443
+ if (!elVideo) {
442
444
  return null;
443
445
  }
444
446
  return spec.currentQuality;
@@ -446,6 +448,25 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
446
448
  that.setCurrentQuality = (qualityIndex) => {
447
449
  //Do nothing
448
450
  };
451
+
452
+ that.getAudioTracks = () => {
453
+ if (!elVideo) {
454
+ return [];
455
+ }
456
+ return spec.audioTracks;
457
+ };
458
+
459
+ that.getCurrentAudioTrack = () => {
460
+ if (!elVideo) {
461
+ return [];
462
+ }
463
+ return spec.currentAudioTrack;
464
+ };
465
+
466
+ that.setCurrentAudioTrack = (audioTrackIndex) => {
467
+ //Do nothing
468
+ };
469
+
449
470
  that.isAutoQuality = () => {
450
471
  //Do nothing
451
472
  };
@@ -459,7 +480,7 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
459
480
  that.setFramerate = (framerate) => {
460
481
  return spec.framerate = framerate;
461
482
  };
462
- that.seekFrame = (frameCount) =>{
483
+ that.seekFrame = (frameCount) => {
463
484
  let fps = spec.framerate;
464
485
  let currentFrames = elVideo.currentTime * fps;
465
486
  let newPosition = (currentFrames + frameCount) / fps;
@@ -469,8 +490,8 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
469
490
  that.seek(newPosition);
470
491
  };
471
492
 
472
- that.stop = () =>{
473
- if(!elVideo){
493
+ that.stop = () => {
494
+ if (!elVideo) {
474
495
  return false;
475
496
  }
476
497
  OvenPlayerConsole.log("CORE : stop() ");
@@ -486,15 +507,15 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
486
507
  isPlayingProcessing = false;
487
508
  };
488
509
 
489
- that.destroy = () =>{
490
- if(!elVideo){
510
+ that.destroy = () => {
511
+ if (!elVideo) {
491
512
  return false;
492
513
  }
493
514
  that.stop();
494
515
  listener.destroy();
495
516
  //elVideo.remove();
496
517
 
497
- if(ads){
518
+ if (ads) {
498
519
  ads.destroy();
499
520
  ads = null;
500
521
  }
@@ -506,7 +527,7 @@ const Provider = function (spec, playerConfig, onExtendedLoad){
506
527
  // use : let super_destroy = that.super('destroy'); ... super_destroy();
507
528
  that.super = (name) => {
508
529
  const method = that[name];
509
- return function(){
530
+ return function () {
510
531
  return method.apply(that, arguments);
511
532
  };
512
533
  };