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
package/src/js/api/Api.js CHANGED
@@ -2,16 +2,37 @@ import OvenPlayerSDK from "ovenplayer.sdk"
2
2
  import CaptionManager from "api/caption/Manager";
3
3
  import Configurator from "api/Configurator";
4
4
  import EventEmitter from "api/EventEmitter";
5
- import LazyCommandExecutor from "api/LazyCommandExecutor";
6
5
  import MediaManager from "api/media/Manager";
7
6
  import PlaylistManager from "api/playlist/Manager";
8
7
  import ProviderController from "api/provider/Controller";
9
- import {READY, ERRORS, ERROR, CONTENT_COMPLETE, CONTENT_META, INIT_UNKNWON_ERROR, INIT_UNSUPPORT_ERROR, DESTROY, PLAYER_PLAY, NETWORK_UNSTABLED, PLAYER_WEBRTC_NETWORK_SLOW, PLAYER_WEBRTC_UNEXPECTED_DISCONNECT, PLAYER_WEBRTC_SET_LOCAL_DESC_ERROR,
10
- PLAYER_FILE_ERROR, PROVIDER_DASH, PROVIDER_HLS, PROVIDER_WEBRTC, PROVIDER_HTML5, PROVIDER_RTMP, ALL_PLAYLIST_ENDED} from "api/constants";
11
- import {version} from 'version';
12
- import {ApiRtmpExpansion} from 'api/ApiExpansions';
13
- import {analUserAgent} from "utils/browser";
14
- import {pickCurrentSource} from "api/provider/utils";
8
+ import {
9
+ READY,
10
+ ERRORS,
11
+ ERROR,
12
+ CONTENT_COMPLETE,
13
+ CONTENT_META,
14
+ INIT_UNKNWON_ERROR,
15
+ INIT_UNSUPPORT_ERROR,
16
+ DESTROY,
17
+ PLAYER_PLAY,
18
+ NETWORK_UNSTABLED,
19
+ PLAYER_WEBRTC_NETWORK_SLOW,
20
+ PLAYER_WEBRTC_UNEXPECTED_DISCONNECT,
21
+ PLAYER_WEBRTC_SET_LOCAL_DESC_ERROR,
22
+ PLAYER_FILE_ERROR,
23
+ PROVIDER_DASH,
24
+ PROVIDER_HLS,
25
+ PROVIDER_WEBRTC,
26
+ PROVIDER_HTML5,
27
+ PROVIDER_RTMP,
28
+ ALL_PLAYLIST_ENDED
29
+ } from "api/constants";
30
+
31
+ import { ApiRtmpExpansion } from 'api/ApiExpansions';
32
+ import { analUserAgent } from "utils/browser";
33
+ import { pickCurrentSource } from "api/provider/utils";
34
+ import { version } from "../version";
35
+ import { CONTENT_SOURCE_CHANGED } from "./constants";
15
36
 
16
37
  /**
17
38
  * @brief This object connects UI to the provider.
@@ -19,11 +40,10 @@ import {pickCurrentSource} from "api/provider/utils";
19
40
  *
20
41
  * */
21
42
 
22
- const Api = function(container){
43
+ const Api = function (container) {
23
44
  const that = {};
24
45
  EventEmitter(that);
25
46
 
26
- console.log("[OvenPlayer] v."+ version);
27
47
  OvenPlayerConsole.log("API loaded.");
28
48
 
29
49
  let playlistManager = PlaylistManager(that);
@@ -32,47 +52,43 @@ const Api = function(container){
32
52
  let mediaManager = MediaManager(container, userAgentObject);
33
53
  let currentProvider = "";
34
54
  let playerConfig = "";
35
- let lazyQueue = "";
36
55
  let captionManager = "";
37
56
 
38
- let webrtcRetryInterval = 1000;
39
-
40
- const runNextPlaylist = function(index){
57
+ const runNextPlaylist = function (index) {
41
58
  OvenPlayerConsole.log("runNextPlaylist");
42
59
  let nextPlaylistIndex = index; // || playlistManager.getCurrentPlaylistIndex() + 1;
43
60
  let playlist = playlistManager.getPlaylist();
44
- let hasNextPlaylist = playlist[nextPlaylistIndex]? true : false;
61
+ let hasNextPlaylist = playlist[nextPlaylistIndex] ? true : false;
45
62
  //init source index
46
63
  playerConfig.setSourceIndex(0);
47
64
 
48
65
  //set Golbal Volume info
49
66
  playerConfig.setVolume(currentProvider.getVolume());
50
67
 
51
- if(hasNextPlaylist){
52
- //that.pause();
53
- lazyQueue = LazyCommandExecutor(that, ['play','seek','stop']);
68
+ if (hasNextPlaylist) {
69
+
54
70
  playlistManager.setCurrentPlaylist(nextPlaylistIndex);
55
71
  initProvider();
56
72
 
57
- }else{
73
+ } else {
58
74
  //All Playlist Ended.
59
75
  that.trigger(ALL_PLAYLIST_ENDED, null);
60
76
  }
61
77
  };
62
- const initProvider = function(lastPlayPosition){
78
+ const initProvider = function (lastPlayPosition) {
63
79
 
64
80
  return providerController.loadProviders(playlistManager.getCurrentPlayList()).then(Providers => {
65
81
 
66
- if(Providers.length < 1){
82
+ if (Providers.length < 1) {
67
83
  throw ERRORS.codes[INIT_UNSUPPORT_ERROR];
68
84
  }
69
85
 
70
- if(currentProvider){
86
+ if (currentProvider) {
71
87
  currentProvider.destroy();
72
88
  currentProvider = null;
73
89
  }
74
90
 
75
- if(captionManager){
91
+ if (captionManager) {
76
92
  captionManager.destroy();
77
93
  captionManager = null;
78
94
  }
@@ -85,35 +101,39 @@ const Api = function(container){
85
101
  let providerName = Providers[currentSourceIndex]["name"];
86
102
  OvenPlayerConsole.log("API : init() provider", providerName);
87
103
  //Init Provider.
88
- currentProvider = Providers[currentSourceIndex].provider(
104
+ currentProvider = Providers[currentSourceIndex].provider(
89
105
  mediaManager.createMedia(providerName, playerConfig),
90
106
  playerConfig,
91
107
  playlistManager.getCurrentAdTag()
92
108
  );
93
109
 
94
- if(providerName === PROVIDER_RTMP){
110
+ if (providerName === PROVIDER_RTMP) {
95
111
  //If provider type is RTMP, we accepts RtmpExpansion.
96
112
  Object.assign(that, ApiRtmpExpansion(currentProvider));
97
113
  }
98
114
 
99
115
  //This passes the event created by the Provider to API.
100
- currentProvider.on("all", function(name, data){
116
+ currentProvider.on("all", function (name, data) {
101
117
 
102
- if( name === ERROR) {
118
+ if (name === ERROR) {
103
119
 
104
120
  // Chrome >=80 on Android misses h246 in SDP when first time after web page loaded.
105
121
  // So wait until browser get h264 capabilities and create answer SDP.
106
- if (userAgentObject.os === 'Android' && userAgentObject.browser === 'Chrome') {
107
-
108
- if (data && data.code && data.code === PLAYER_WEBRTC_SET_LOCAL_DESC_ERROR) {
109
-
110
- setTimeout(function () {
111
-
112
- that.setCurrentSource(that.getCurrentSource());
113
- }, webrtcRetryInterval);
114
-
115
- return;
116
- }
122
+ // if (userAgentObject.os === 'Android' && userAgentObject.browser === 'Chrome') {
123
+ //
124
+ // if (data && data.code && data.code === PLAYER_WEBRTC_SET_LOCAL_DESC_ERROR) {
125
+ //
126
+ // setTimeout(function () {
127
+ //
128
+ // that.setCurrentSource(that.getCurrentSource());
129
+ // }, webrtcRetryInterval);
130
+ //
131
+ // return;
132
+ // }
133
+ // }
134
+
135
+ if (providerName === PROVIDER_WEBRTC) {
136
+ currentProvider.removeStream();
117
137
  }
118
138
 
119
139
  if (playerConfig.getConfig().autoFallback && that.getCurrentSource() + 1 < that.getSources().length) {
@@ -125,7 +145,7 @@ const Api = function(container){
125
145
  }
126
146
  }
127
147
 
128
- if(name === CONTENT_COMPLETE){
148
+ if (name === CONTENT_COMPLETE) {
129
149
  runNextPlaylist(playlistManager.getCurrentPlaylistIndex() + 1);
130
150
  }
131
151
 
@@ -138,20 +158,22 @@ const Api = function(container){
138
158
  that.trigger(name, data);
139
159
  });
140
160
 
141
- }).then(()=>{
161
+ that.trigger(CONTENT_SOURCE_CHANGED, {
162
+ currentSource: currentSourceIndex
163
+ });
164
+
165
+
166
+ }).then(() => {
142
167
 
143
168
  //provider's preload() have to made Promise. Cuz it overcomes 'flash loading timing problem'.
144
- currentProvider.preload(playlistManager.getCurrentSources(), lastPlayPosition).then(function(){
169
+ currentProvider.preload(playlistManager.getCurrentSources(), lastPlayPosition).then(function () {
145
170
 
146
- lazyQueue.flush();
147
- //This is no reason to exist anymore.
148
- lazyQueue.destroy();
149
171
 
150
172
  }).catch((error) => {
151
- lazyQueue.off();
152
- if(error && error.code && ERRORS.codes[error.code]){
173
+
174
+ if (error && error.code && ERRORS.codes[error.code]) {
153
175
  that.trigger(ERROR, ERRORS.codes[error.code]);
154
- }else {
176
+ } else {
155
177
  let tempError = ERRORS.codes[INIT_UNKNWON_ERROR];
156
178
  tempError.error = error;
157
179
  that.trigger(ERROR, tempError);
@@ -159,20 +181,13 @@ const Api = function(container){
159
181
  });
160
182
  }).catch((error) => {
161
183
  //INIT ERROR
162
- if(error && error.code && ERRORS.codes[error.code]){
184
+ if (error && error.code && ERRORS.codes[error.code]) {
163
185
  that.trigger(ERROR, ERRORS.codes[error.code]);
164
- }else {
186
+ } else {
165
187
  let tempError = ERRORS.codes[INIT_UNKNWON_ERROR];
166
188
  tempError.error = error;
167
189
  that.trigger(ERROR, tempError);
168
190
  }
169
-
170
- //xxx : If you init empty sources. (I think this is strange case.)
171
- //This works for this case.
172
- //player = OvenPlayer.create("elId", {});
173
- //player.load(soruces);
174
- lazyQueue.off();
175
- //lazyQueue.removeAndExcuteOnce("load");
176
191
  });
177
192
  };
178
193
 
@@ -182,17 +197,12 @@ const Api = function(container){
182
197
  * @param {object} options player initial option value.
183
198
  * @returns
184
199
  **/
185
- that.init = (options) =>{
200
+ that.init = (options) => {
186
201
 
187
202
  if (!options) {
188
203
  options = {};
189
204
  }
190
205
 
191
- //It collects the commands and executes them at the time when they are executable.
192
- lazyQueue = LazyCommandExecutor(that, [
193
- 'load','play','pause','seek','stop', 'getDuration', 'getPosition', 'getVolume'
194
- , 'getMute', 'getBuffer', 'getState' , 'getQualityLevels'
195
- ]);
196
206
  options.mediaContainer = container;
197
207
  options.browser = userAgentObject;
198
208
  playerConfig = Configurator(options, that);
@@ -205,7 +215,7 @@ const Api = function(container){
205
215
  //ERRORS.codes.push(playerConfig.getSystemText());
206
216
 
207
217
  playlistManager.initPlaylist(playerConfig.getPlaylist(), playerConfig);
208
- OvenPlayerConsole.log("API : init() sources : " , playlistManager.getCurrentSources());
218
+ OvenPlayerConsole.log("API : init() sources : ", playlistManager.getCurrentSources());
209
219
 
210
220
  initProvider();
211
221
 
@@ -214,17 +224,20 @@ const Api = function(container){
214
224
  });
215
225
  };
216
226
  that.getProviderName = () => {
217
- if(currentProvider){
227
+ if (currentProvider) {
218
228
  return currentProvider.getName();
219
- }else{
229
+ } else {
220
230
  return null;
221
231
  }
222
232
 
223
233
  };
234
+ that.getProvider = () => {
235
+ return currentProvider;
236
+ };
224
237
  that.getMseInstance = () => {
225
- if(currentProvider){
238
+ if (currentProvider) {
226
239
  return currentProvider.getMse();
227
- }else{
240
+ } else {
228
241
  return null;
229
242
  }
230
243
 
@@ -237,7 +250,7 @@ const Api = function(container){
237
250
 
238
251
  return playerConfig.getBrowser();
239
252
  };
240
- that.setTimecodeMode = (isShow) =>{
253
+ that.setTimecodeMode = (isShow) => {
241
254
  OvenPlayerConsole.log("API : setTimecodeMode()", isShow);
242
255
  playerConfig.setTimecodeMode(isShow);
243
256
  };
@@ -254,56 +267,78 @@ const Api = function(container){
254
267
 
255
268
  };
256
269
  that.seekFrame = (frameCount) => {
257
- if(!currentProvider){return null;}
270
+ if (!currentProvider) {
271
+ return null;
272
+ }
258
273
  OvenPlayerConsole.log("API : seekFrame()", frameCount);
259
274
  return currentProvider.seekFrame(frameCount);
260
275
  };
261
-
262
276
  that.getDuration = () => {
263
- if(!currentProvider){return null;}
277
+ if (!currentProvider) {
278
+ return null;
279
+ }
264
280
  OvenPlayerConsole.log("API : getDuration()", currentProvider.getDuration());
265
281
  return currentProvider.getDuration();
266
282
  };
283
+ that.getDvrWindow = () => {
284
+ if (!currentProvider) {
285
+ return null;
286
+ }
287
+ OvenPlayerConsole.log("API : getDvrWindow()", currentProvider.getDvrWindow());
288
+ return currentProvider.getDvrWindow();
289
+ };
267
290
  that.getPosition = () => {
268
- if(!currentProvider){return null;}
291
+ if (!currentProvider) {
292
+ return null;
293
+ }
269
294
 
270
295
  OvenPlayerConsole.log("API : getPosition()", currentProvider.getPosition());
271
296
  return currentProvider.getPosition();
272
297
  };
273
298
  that.getVolume = () => {
274
- if(!currentProvider){return null;}
299
+ if (!currentProvider) {
300
+ return null;
301
+ }
275
302
 
276
303
  OvenPlayerConsole.log("API : getVolume()", currentProvider.getVolume());
277
304
  return currentProvider.getVolume();
278
305
  };
279
306
  that.setVolume = (volume) => {
280
- if(!currentProvider){return null;}
307
+ if (!currentProvider) {
308
+ return null;
309
+ }
281
310
 
282
311
  OvenPlayerConsole.log("API : setVolume() " + volume);
283
312
  currentProvider.setVolume(volume);
284
313
  };
285
314
  that.setMute = (state) => {
286
- if(!currentProvider){return null;}
315
+ if (!currentProvider) {
316
+ return null;
317
+ }
287
318
 
288
319
  OvenPlayerConsole.log("API : setMute() " + state);
289
320
  return currentProvider.setMute(state);
290
321
  };
291
322
  that.getMute = () => {
292
- if(!currentProvider){return null;}
323
+ if (!currentProvider) {
324
+ return null;
325
+ }
293
326
 
294
327
  OvenPlayerConsole.log("API : getMute() " + currentProvider.getMute());
295
328
  return currentProvider.getMute();
296
329
  };
297
330
  that.load = (playlist) => {
298
331
  OvenPlayerConsole.log("API : load() ", playlist);
299
- lazyQueue = LazyCommandExecutor(that, ['play','seek','stop']);
300
332
 
301
- if(playlist){
333
+ if (playlist) {
302
334
 
303
335
  playerConfig.setSourceIndex(0);
304
336
 
305
- if(currentProvider){
306
- currentProvider.setCurrentQuality(0);
337
+ if (currentProvider) {
338
+
339
+ if (currentProvider.getQualityLevels().length > 0) {
340
+ currentProvider.setCurrentQuality(0);
341
+ }
307
342
  }
308
343
 
309
344
  if ('sources' in playlist) {
@@ -320,7 +355,9 @@ const Api = function(container){
320
355
 
321
356
  };
322
357
  that.play = () => {
323
- if(!currentProvider){return null;}
358
+ if (!currentProvider) {
359
+ return null;
360
+ }
324
361
  OvenPlayerConsole.log("API : play() ");
325
362
 
326
363
  if (!currentProvider.metaLoaded() && !playerConfig.isAutoStart()) {
@@ -332,25 +369,33 @@ const Api = function(container){
332
369
  }
333
370
  };
334
371
  that.pause = () => {
335
- if(!currentProvider){return null;}
372
+ if (!currentProvider) {
373
+ return null;
374
+ }
336
375
 
337
376
  OvenPlayerConsole.log("API : pause() ");
338
377
  currentProvider.pause();
339
378
  };
340
379
  that.seek = (position) => {
341
- if(!currentProvider){return null;}
380
+ if (!currentProvider) {
381
+ return null;
382
+ }
342
383
 
343
- OvenPlayerConsole.log("API : seek() "+ position);
384
+ OvenPlayerConsole.log("API : seek() " + position);
344
385
  currentProvider.seek(position);
345
386
  };
346
- that.setPlaybackRate = (playbackRate) =>{
347
- if(!currentProvider){return null;}
387
+ that.setPlaybackRate = (playbackRate) => {
388
+ if (!currentProvider) {
389
+ return null;
390
+ }
348
391
 
349
392
  OvenPlayerConsole.log("API : setPlaybackRate() ", playbackRate);
350
393
  return currentProvider.setPlaybackRate(playerConfig.setPlaybackRate(playbackRate));
351
394
  };
352
- that.getPlaybackRate = () =>{
353
- if(!currentProvider){return null;}
395
+ that.getPlaybackRate = () => {
396
+ if (!currentProvider) {
397
+ return null;
398
+ }
354
399
 
355
400
  OvenPlayerConsole.log("API : getPlaybackRate() ", currentProvider.getPlaybackRate());
356
401
  return currentProvider.getPlaybackRate();
@@ -370,118 +415,167 @@ const Api = function(container){
370
415
  };
371
416
 
372
417
  that.getSources = () => {
373
- if(!currentProvider){return null;}
418
+ if (!currentProvider) {
419
+ return null;
420
+ }
374
421
 
375
422
  OvenPlayerConsole.log("API : getSources() ", currentProvider.getSources());
376
423
  return currentProvider.getSources();
377
424
  };
378
- that.getCurrentSource = () =>{
379
- if(!currentProvider){return null;}
425
+ that.getCurrentSource = () => {
426
+ if (!currentProvider) {
427
+ return null;
428
+ }
380
429
 
381
430
  OvenPlayerConsole.log("API : getCurrentSource() ", currentProvider.getCurrentSource());
382
431
  return currentProvider.getCurrentSource();
383
432
  };
384
- that.setCurrentSource = (index) =>{
433
+ that.setCurrentSource = (index) => {
385
434
 
386
- if(!currentProvider){return null;}
435
+ if (!currentProvider) {
436
+ return null;
437
+ }
387
438
 
388
439
  OvenPlayerConsole.log("API : setCurrentSource() ", index);
389
440
 
390
- // let sources = currentProvider.getSources();
391
- // let currentSource = sources[currentProvider.getCurrentSource()];
392
- // let newSource = sources[index];
393
-
394
- // let isSameProvider = providerController.isSameProvider(currentSource, newSource);
395
- // // provider.serCurrentQuality -> playerConfig setting -> load
396
- // let resultSourceIndex = currentProvider.setCurrentSource(index, isSameProvider);
397
- //
398
- // if(!newSource){
399
- // return null;
400
- // }
401
- //
402
- // OvenPlayerConsole.log("API : setCurrentQuality() isSameProvider", isSameProvider);
403
-
404
441
  let lastPlayPosition = currentProvider.getPosition();
405
442
  playerConfig.setSourceIndex(index);
406
- lazyQueue = LazyCommandExecutor(that, ['play','seek']);
407
443
 
408
- initProvider(lastPlayPosition);
444
+ initProvider(lastPlayPosition).then(function () {
445
+
446
+ that.trigger(CONTENT_SOURCE_CHANGED, {
447
+ currentSource: index
448
+ });
449
+ });
409
450
 
410
451
  return index;
411
452
  };
412
453
 
413
454
 
414
-
415
- that.getQualityLevels = () =>{
416
- if(!currentProvider){return null;}
455
+ that.getQualityLevels = () => {
456
+ if (!currentProvider) {
457
+ return null;
458
+ }
417
459
 
418
460
  OvenPlayerConsole.log("API : getQualityLevels() ", currentProvider.getQualityLevels());
419
461
  return currentProvider.getQualityLevels();
420
462
  };
421
- that.getCurrentQuality = () =>{
422
- if(!currentProvider){return null;}
463
+ that.getCurrentQuality = () => {
464
+ if (!currentProvider) {
465
+ return null;
466
+ }
423
467
 
424
468
  OvenPlayerConsole.log("API : getCurrentQuality() ", currentProvider.getCurrentQuality());
425
469
  return currentProvider.getCurrentQuality();
426
470
  };
427
- that.setCurrentQuality = (qualityIndex) =>{
428
- if(!currentProvider){return null;}
471
+ that.setCurrentQuality = (qualityIndex) => {
472
+ if (!currentProvider) {
473
+ return null;
474
+ }
429
475
 
430
476
  OvenPlayerConsole.log("API : setCurrentQuality() ", qualityIndex);
431
477
 
432
478
  return currentProvider.setCurrentQuality(qualityIndex);
433
479
  };
480
+
481
+ that.getAudioTracks = () => {
482
+ if (!currentProvider) {
483
+ return null;
484
+ }
485
+
486
+ OvenPlayerConsole.log("API : getAudioTracks() ", currentProvider.getAudioTracks());
487
+ return currentProvider.getAudioTracks();
488
+ };
489
+
490
+ that.getCurrentAudioTrack = () => {
491
+ if (!currentProvider) {
492
+ return null;
493
+ }
494
+
495
+ OvenPlayerConsole.log("API : getCurrentAudioTrack() ", currentProvider.getCurrentAudioTrack());
496
+ return currentProvider.getCurrentAudioTrack();
497
+ };
498
+
499
+ that.setCurrentAudioTrack = (audioTrackIndex) => {
500
+ if (!currentProvider) {
501
+ return null;
502
+ }
503
+
504
+ OvenPlayerConsole.log("API : setCurrentAudioTrack() ", audioTrackIndex);
505
+ return currentProvider.setCurrentAudioTrack(audioTrackIndex);
506
+ };
507
+
434
508
  that.isAutoQuality = () => {
435
- if(!currentProvider){return null;}
509
+ if (!currentProvider) {
510
+ return null;
511
+ }
436
512
 
437
513
  OvenPlayerConsole.log("API : isAutoQuality()");
438
514
  return currentProvider.isAutoQuality();
439
515
  };
440
516
  that.setAutoQuality = (isAuto) => {
441
- if(!currentProvider){return null;}
517
+ if (!currentProvider) {
518
+ return null;
519
+ }
442
520
 
443
521
  OvenPlayerConsole.log("API : setAutoQuality() ", isAuto);
444
522
  return currentProvider.setAutoQuality(isAuto);
445
523
  };
446
524
 
447
525
  that.getCaptionList = () => {
448
- if(!captionManager){return null;}
526
+ if (!captionManager) {
527
+ return null;
528
+ }
449
529
  OvenPlayerConsole.log("API : getCaptionList() ", captionManager.getCaptionList());
450
530
  return captionManager.getCaptionList();
451
531
  };
452
532
  that.getCurrentCaption = () => {
453
- if(!captionManager){return null;}
533
+ if (!captionManager) {
534
+ return null;
535
+ }
454
536
  OvenPlayerConsole.log("API : getCurrentCaption() ", captionManager.getCurrentCaption());
455
537
  return captionManager.getCurrentCaption();
456
538
  };
457
539
  that.setCurrentCaption = (index) => {
458
- if(!captionManager){return null;}
540
+ if (!captionManager) {
541
+ return null;
542
+ }
459
543
  OvenPlayerConsole.log("API : setCurrentCaption() ", index);
460
544
  captionManager.setCurrentCaption(index);
461
545
  };
462
546
  that.addCaption = (track) => {
463
- if(!captionManager){return null;}
547
+ if (!captionManager) {
548
+ return null;
549
+ }
464
550
  OvenPlayerConsole.log("API : addCaption() ")
465
551
  return captionManager.addCaption(track);
466
552
  };
467
553
  that.removeCaption = (index) => {
468
- if(!captionManager){return null;}
554
+ if (!captionManager) {
555
+ return null;
556
+ }
469
557
  OvenPlayerConsole.log("API : removeCaption() ", index)
470
558
  return captionManager.removeCaption(index);
471
559
  };
472
560
 
473
561
  that.getBuffer = () => {
474
- if(!currentProvider){return null;}
562
+ if (!currentProvider) {
563
+ return null;
564
+ }
475
565
  OvenPlayerConsole.log("API : getBuffer() ", currentProvider.getBuffer());
476
566
  currentProvider.getBuffer();
477
567
  };
478
568
  that.getState = () => {
479
- if(!currentProvider){return null;}
569
+ if (!currentProvider) {
570
+ return null;
571
+ }
480
572
  OvenPlayerConsole.log("API : getState() ", currentProvider.getState());
481
573
  return currentProvider.getState();
482
574
  };
483
575
  that.stop = () => {
484
- if(!currentProvider){return null;}
576
+ if (!currentProvider) {
577
+ return null;
578
+ }
485
579
 
486
580
  OvenPlayerConsole.log("API : stop() ");
487
581
  currentProvider.stop();
@@ -490,21 +584,17 @@ const Api = function(container){
490
584
 
491
585
  OvenPlayerConsole.log("API : remove() ");
492
586
 
493
- if (lazyQueue) {
494
- lazyQueue.destroy();
495
- }
496
-
497
- if(captionManager){
587
+ if (captionManager) {
498
588
  captionManager.destroy();
499
589
  captionManager = null;
500
590
  }
501
591
 
502
- if(currentProvider){
592
+ if (currentProvider) {
503
593
  currentProvider.destroy();
504
594
  currentProvider = null;
505
595
  }
506
596
 
507
- if(mediaManager){
597
+ if (mediaManager) {
508
598
  mediaManager.destroy();
509
599
  mediaManager = null;
510
600
  }
@@ -515,24 +605,25 @@ const Api = function(container){
515
605
  providerController = null;
516
606
  playlistManager = null;
517
607
  playerConfig = null;
518
- lazyQueue = null;
519
608
 
520
- OvenPlayerConsole.log("API : remove() - lazyQueue, currentProvider, providerController, playlistManager, playerConfig, api event destroed. ");
521
- OvenPlayerSDK.removePlayer(that.getContainerId());
522
- if(OvenPlayerSDK.getPlayerList().length === 0){
523
- OvenPlayerConsole.log("OvenPlayerSDK.playerList", OvenPlayerSDK.getPlayerList());
524
- }
609
+ OvenPlayerConsole.log("API : remove() - currentProvider, providerController, playlistManager, playerConfig, api event destroed. ");
610
+ OvenPlayerSDK.removePlayer(that);
611
+
612
+ };
613
+
614
+ that.getMediaElement = () => {
615
+
616
+ return currentProvider.getMediaElement();
525
617
  };
526
618
 
527
619
  that.getVersion = () => {
528
- return "v."+version;
620
+ return version;
529
621
  };
530
622
 
531
623
  return that;
532
624
  };
533
625
 
534
626
 
535
-
536
627
  export default Api;
537
628
 
538
629