ovenplayer 0.10.13 → 0.10.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ovenplayer",
3
- "version": "0.10.13",
3
+ "version": "0.10.17",
4
4
  "description": "OvenPlayer is Open-Source HTML5 Player. OvenPlayer supports WebRTC Signaling from OvenMediaEngine for Sub-Second Latency Streaming.",
5
5
  "main": "dist/ovenplayer.js",
6
6
  "scripts": {
@@ -45,4 +45,4 @@
45
45
  "core-js": "^3.16.3",
46
46
  "whatwg-fetch": "^3.6.2"
47
47
  }
48
- }
48
+ }
package/src/js/api/Api.js CHANGED
@@ -477,10 +477,8 @@ const Api = function(container){
477
477
  playerConfig = null;
478
478
 
479
479
  OvenPlayerConsole.log("API : remove() - currentProvider, providerController, playlistManager, playerConfig, api event destroed. ");
480
- OvenPlayerSDK.removePlayer(that.getContainerId());
481
- if(OvenPlayerSDK.getPlayerList().length === 0){
482
- OvenPlayerConsole.log("OvenPlayerSDK.playerList", OvenPlayerSDK.getPlayerList());
483
- }
480
+ OvenPlayerSDK.removePlayer(that);
481
+
484
482
  };
485
483
 
486
484
  that.getMediaElement = () => {
@@ -10,8 +10,6 @@ import {version} from 'version';
10
10
 
11
11
  const Manager = function(container, browserInfo){
12
12
  const that = {};
13
- const SWFPath = '';
14
- let rootId = container.getAttribute("data-parent-id");
15
13
  let $container = LA$(container);
16
14
  let videoElement = "";
17
15
 
@@ -33,111 +31,19 @@ const Manager = function(container, browserInfo){
33
31
 
34
32
  return videoElement;
35
33
  };
36
- const createFlashVideo = function(isLoop, bufferTime, bufferTimeMax){
37
- let movie, flashvars, allowscriptaccess, allowfullscreen, quality, name, menu, qual, bgcolor, loop, wmode ;
38
- OvenPlayerConsole.log("MediaManager Flash buffer setting : ", bufferTime, bufferTimeMax);
39
- movie = document.createElement('param');
40
- movie.setAttribute('name', 'movie');
41
- movie.setAttribute('value', SWFPath);
42
-
43
- flashvars = document.createElement('param');
44
- flashvars.setAttribute('name', 'flashvars');
45
- //playerId is to use SWF for ExternalInterface.call().
46
- flashvars.setAttribute('value', `playerId=${rootId}&bufferTime=${bufferTime}&bufferMaxTime=${bufferTimeMax}`);
47
-
48
- allowscriptaccess = document.createElement('param');
49
- allowscriptaccess.setAttribute('name', 'allowscriptaccess');
50
- allowscriptaccess.setAttribute('value', 'always');
51
-
52
- allowfullscreen = document.createElement('param');
53
- allowfullscreen.setAttribute('name', 'allowfullscreen');
54
- allowfullscreen.setAttribute('value', 'true');
55
-
56
- quality = document.createElement('param');
57
- quality.setAttribute('name', 'quality');
58
- quality.setAttribute('value', 'height');
59
-
60
- name = document.createElement('param');
61
- name.setAttribute('name', 'name');
62
- name.setAttribute('value', rootId+"-flash");
63
-
64
- menu = document.createElement('param');
65
- menu.setAttribute('name', 'menu');
66
- menu.setAttribute('value', 'false');
67
-
68
- qual = document.createElement('param');
69
- qual.setAttribute('name', 'quality');
70
- qual.setAttribute('value', 'high');
71
-
72
- bgcolor = document.createElement('param');
73
- bgcolor.setAttribute('name', 'bgcolor');
74
- bgcolor.setAttribute('value', '#000000');
75
-
76
- wmode = document.createElement('param');
77
- wmode.setAttribute('name', 'wmode');
78
- wmode.setAttribute('value', 'opaque');
79
-
80
- /*let allowButton = `<a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player"></a>`;
81
- message = document.createElement("div");
82
- message.innerHTML = allowButton;*/
83
-
84
- if(isLoop){
85
- loop = document.createElement('param');
86
- loop.setAttribute('name', 'loop');
87
- loop.setAttribute('value', 'true');
88
- }
89
-
90
- videoElement = document.createElement('object');
91
- videoElement.setAttribute('id', rootId+"-flash");
92
- videoElement.setAttribute('name', rootId+"-flash");
93
- videoElement.setAttribute('width', '100%');
94
- videoElement.setAttribute('height', '100%');
95
- videoElement.setAttribute('scale', 'default');
96
- videoElement.setAttribute('wmode', 'opaque');
97
-
98
- if(browserInfo.browser === "Microsoft Internet Explorer" && browserInfo.browserMajorVersion <= 9 ){
99
- videoElement.setAttribute('classid', 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000');
100
- videoElement.appendChild(movie);
101
- }else{
102
- videoElement.setAttribute('data', SWFPath);
103
- videoElement.setAttribute('type', 'application/x-shockwave-flash');
104
- }
105
- if(isLoop){
106
- videoElement.appendChild(loop);
107
- }
108
-
109
- videoElement.appendChild(wmode);
110
- videoElement.appendChild(bgcolor);
111
- videoElement.appendChild(qual);
112
- videoElement.appendChild(allowfullscreen);
113
- videoElement.appendChild(allowscriptaccess);
114
- videoElement.appendChild(flashvars);
115
- //videoElement.appendChild(message);
116
-
117
- $container.append(videoElement);
118
-
119
- return videoElement;
120
- };
121
34
 
122
35
  that.createMedia = (providerName , playerConfig) => {
123
- if( providerName === PROVIDER_RTMP ){
124
- if(videoElement){
125
- that.empty();
126
- }
127
- return createFlashVideo(playerConfig.isLoop(), playerConfig.getRtmpBufferTime(), playerConfig.getRtmpBufferTimeMax());
128
- }else{
129
- // if(videoElement){
130
- // // that.empty();
131
- // //reuse video element.
132
- // //because playlist is auto next playing.
133
- // //Only same video element does not require User Interaction Error.
134
- // return videoElement;
135
- // }else{
136
- // return createHtmlVideo(playerConfig.isLoop(), playerConfig.isAutoStart());
137
- // }
138
- that.empty();
139
- return createHtmlVideo(playerConfig.isLoop(), playerConfig.isAutoStart());
140
- }
36
+ // if(videoElement){
37
+ // // that.empty();
38
+ // //reuse video element.
39
+ // //because playlist is auto next playing.
40
+ // //Only same video element does not require User Interaction Error.
41
+ // return videoElement;
42
+ // }else{
43
+ // return createHtmlVideo(playerConfig.isLoop(), playerConfig.isAutoStart());
44
+ // }
45
+ that.empty();
46
+ return createHtmlVideo(playerConfig.isLoop(), playerConfig.isAutoStart());
141
47
  }
142
48
 
143
49
  that.createAdContainer = () => {
@@ -159,7 +65,6 @@ const Manager = function(container, browserInfo){
159
65
  $container.removeChild();
160
66
  $container = null;
161
67
  videoElement = null;
162
- rootId = null;
163
68
  };
164
69
 
165
70
  return that;
@@ -143,8 +143,6 @@ const WebRTC = function (element, playerConfig, adTagUrl) {
143
143
  playerConfig
144
144
  );
145
145
 
146
- that.setState(STATE_LOADING);
147
-
148
146
  connectionStartTime = performance.now();
149
147
  webrtcLoader.connect();
150
148
 
@@ -203,13 +201,14 @@ const WebRTC = function (element, playerConfig, adTagUrl) {
203
201
 
204
202
  if (config.webrtcConfig) {
205
203
 
206
- if (config.webrtcConfig.connectionTimeout) {
204
+ if (typeof config.webrtcConfig.connectionTimeout === 'number'
205
+ && config.webrtcConfig.connectionTimeout > 0) {
207
206
 
208
207
  connectionTimeout = config.webrtcConfig.connectionTimeout;
209
208
  }
210
209
 
211
- if (config.webrtcConfig.timeoutMaxRetry ||
212
- config.webrtcConfig.timeoutMaxRetry === 0) {
210
+ if (typeof config.webrtcConfig.timeoutMaxRetry === 'number'
211
+ && config.webrtcConfig.timeoutMaxRetry > 0) {
213
212
 
214
213
  timeoutMaxRetry = config.webrtcConfig.timeoutMaxRetry;
215
214
  }
@@ -40,12 +40,12 @@ const WebRTCLoader = function (provider,
40
40
  //closed websocket by ome or client.
41
41
  let wsClosedByPlayer = false;
42
42
 
43
- let recorverPacketLoss = false;
43
+ let recoverPacketLoss = false;
44
44
 
45
45
  if (playerConfig.getConfig().webrtcConfig &&
46
- playerConfig.getConfig().webrtcConfig.recorverPacketLoss === true) {
46
+ playerConfig.getConfig().webrtcConfig.recoverPacketLoss === true) {
47
47
 
48
- recorverPacketLoss = true;
48
+ recoverPacketLoss = true;
49
49
  }
50
50
 
51
51
  let generatePublicCandidate = true;
@@ -392,10 +392,11 @@ const WebRTCLoader = function (provider,
392
392
  //ConnectionState
393
393
  OvenPlayerConsole.log("[on connection state change]", peerConnection.connectionState, e);
394
394
 
395
+ // firefox and opera do not support onconnectionstatechange (Jan 07, 2021)
396
+ // double check with oniceconnectionstatechange
395
397
  if (peerConnection.connectionState === 'connected') {
396
398
 
397
399
  if (connectedCallback) {
398
-
399
400
  connectedCallback();
400
401
  }
401
402
  }
@@ -412,6 +413,12 @@ const WebRTCLoader = function (provider,
412
413
  peerConnection.oniceconnectionstatechange = function (e) {
413
414
  OvenPlayerConsole.log("[on ice connection state change]", peerConnection.iceConnectionState, e);
414
415
 
416
+ if (peerConnection.iceConnectionState === 'connected') {
417
+
418
+ if (connectedCallback) {
419
+ connectedCallback();
420
+ }
421
+ }
415
422
  /*
416
423
  * https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/iceConnectionState
417
424
  * Checks to ensure that components are still connected failed for at least one component of the RTCPeerConnection. This is a less stringent test than "failed" and may trigger intermittently and resolve just as spontaneously on less reliable networks, or during temporary disconnections. When the problem resolves, the connection may return to the "connected" state.
@@ -432,9 +439,9 @@ const WebRTCLoader = function (provider,
432
439
 
433
440
  OvenPlayerConsole.log("stream received.");
434
441
 
435
- OvenPlayerConsole.log('Recovery On Packet Loss :', recorverPacketLoss);
442
+ OvenPlayerConsole.log('Recovery On Packet Loss :', recoverPacketLoss);
436
443
 
437
- if (recorverPacketLoss) {
444
+ if (recoverPacketLoss) {
438
445
  extractLossPacketsOnNetworkStatus(mainPeerConnectionInfo);
439
446
  }
440
447
 
@@ -19,13 +19,6 @@ function ovenPlayerFactory() {
19
19
 
20
20
  const playerInstance = OvenPlayerSDK.create(player.getMediaElementContainer(), options);
21
21
 
22
-
23
- Object.assign(playerInstance, {
24
- getContainerId: function () {
25
- return containerElement.id;
26
- }
27
- });
28
-
29
22
  player.setApi(playerInstance);
30
23
 
31
24
  return playerInstance;
@@ -84,20 +84,19 @@ function ovenPlayerFactory() {
84
84
  };
85
85
 
86
86
  /**
87
- * Remove the player instance by playerId.
87
+ * Remove the player instance by playerInstance.
88
88
  *
89
- * @param {playerId} id
89
+ * @param {playerInstance} playerInstance
90
90
  * @return {null}
91
91
  */
92
- OvenPlayerSDK.removePlayer = function (playerId) {
93
- for (let i = 0; i < playerList.length; i++) {
92
+ OvenPlayerSDK.removePlayer = function (playerInstance) {
94
93
 
95
- if (playerList[i].getContainerId() === playerId) {
94
+ for (let i = 0; i < playerList.length; i++) {
96
95
 
96
+ if (playerList[i] === playerInstance) {
97
97
  playerList.splice(i, 1);
98
98
  }
99
99
  }
100
-
101
100
  };
102
101
 
103
102
  /**
@@ -13,6 +13,9 @@ import dom from 'utils/polyfills/dom.js';
13
13
 
14
14
  const La$ = function(selectorOrElement){
15
15
  const that = {};
16
+
17
+ let $element = null;
18
+
16
19
  const returnNode = function($element , selector){
17
20
  let nodeList = $element.querySelectorAll(selector);
18
21
  if(nodeList.length > 1){
@@ -23,8 +26,6 @@ const La$ = function(selectorOrElement){
23
26
 
24
27
  };
25
28
 
26
- let $element = "";
27
-
28
29
  if( _.isElement(selectorOrElement) || _.every(selectorOrElement, function(item){return _.isElement(item)})){
29
30
  $element = selectorOrElement;
30
31
  }else if(selectorOrElement === "document"){
@@ -158,7 +159,7 @@ const La$ = function(selectorOrElement){
158
159
  };
159
160
 
160
161
  that.offset = () =>{ //IE8+
161
- var rect = $element.getBoundingClientRect();
162
+ const rect = $element.getBoundingClientRect();
162
163
 
163
164
  return {
164
165
  top: rect.top + document.body.scrollTop,
@@ -16,9 +16,7 @@ import {
16
16
 
17
17
 
18
18
  const FullScreenButton = function($container, api){
19
- const $root = LA$("#"+api.getContainerId());
20
-
21
- // console.log("#"+api.getContainerId() , LA$("#"+api.getContainerId()));
19
+ const $root = LA$(api.getContainerElement());
22
20
 
23
21
  let $iconExpand = "", $iconCompress = "", isFullScreen = false;
24
22
 
@@ -42,7 +40,20 @@ const FullScreenButton = function($container, api){
42
40
  api.toggleFullScreen = toggleFullScreen;
43
41
 
44
42
  function checkFullScreen(){
45
- return document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement;
43
+
44
+ let fullScreen = false;
45
+
46
+ const fullScreenElement = document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement;
47
+
48
+ if (fullScreenElement) {
49
+
50
+ if ($root.get() === fullScreenElement) {
51
+ fullScreen = true;
52
+ }
53
+ }
54
+
55
+ return fullScreen;
56
+
46
57
  };
47
58
 
48
59
  function resetFullscreenButtonState(){
@@ -39,7 +39,7 @@ const Controls = function ($container, api) {
39
39
  let isAndroid = browser.os === "Android";
40
40
  let isIOS = browser.os === "iOS";
41
41
 
42
- const $root = LA$("#" + api.getContainerId());
42
+ const $root = LA$(api.getContainerElement());
43
43
  let lastContentMeta = {};
44
44
 
45
45
  hasPlaylist = api.getPlaylist().length > 1;
@@ -11,7 +11,7 @@ import {
11
11
  } from "api/constants";
12
12
 
13
13
  const PlaylistPanel = function($container, api){
14
- const $root = LA$("#"+api.getContainerId());
14
+ const $root = LA$(api.getContainerElement());
15
15
 
16
16
  let $playlistPanel = "";
17
17
  let playlist = api.getPlaylist();
@@ -13,7 +13,7 @@ import {
13
13
  import {STATE_COMPLETE} from "../../../api/constants";
14
14
 
15
15
  const ProgressBar = function($container, api, isAd){
16
- const $root = LA$("#"+api.getContainerId());
16
+ const $root = LA$(api.getContainerElement());
17
17
 
18
18
  if (api.getConfig().disableSeekUI) {
19
19
  $container.addClass('op-progressbar-container-disabled');
@@ -7,7 +7,7 @@ import LA$ from 'utils/likeA$';
7
7
 
8
8
 
9
9
  const CaptionPanel = function($container, api, data){
10
- const $root = LA$("#"+api.getContainerId());
10
+ const $root = LA$(api.getContainerElement());
11
11
  let panelManager = PanelManager();
12
12
 
13
13
  data.setFront = function(isFront){
@@ -26,7 +26,7 @@ let PANEL_TITLE = {
26
26
 
27
27
  const Panels = function($container, api, data){
28
28
 
29
- const $root = LA$("#"+api.getContainerId());
29
+ const $root = LA$(api.getContainerElement());
30
30
  let panelManager = PanelManager();
31
31
 
32
32
  let playerConfig = api.getConfig();
@@ -10,7 +10,7 @@ import {
10
10
  } from "api/constants";
11
11
 
12
12
  const QualityPanel = function($container, api, data){
13
- const $root = LA$("#"+api.getContainerId());
13
+ const $root = LA$(api.getContainerElement());
14
14
  let panelManager = PanelManager();
15
15
 
16
16
  data.setFront = function(isFront){
@@ -7,7 +7,7 @@ import LA$ from 'utils/likeA$';
7
7
 
8
8
 
9
9
  const SourcePanel = function($container, api, data){
10
- const $root = LA$("#"+api.getContainerId());
10
+ const $root = LA$(api.getContainerElement());
11
11
  let panelManager = PanelManager();
12
12
 
13
13
  data.setFront = function(isFront){
@@ -7,7 +7,7 @@ import LA$ from 'utils/likeA$';
7
7
 
8
8
 
9
9
  const SpeedPanel = function($container, api, data){
10
- const $root = LA$("#"+api.getContainerId());
10
+ const $root = LA$(api.getContainerElement());
11
11
  let panelManager = PanelManager();
12
12
 
13
13
  data.setFront = function(isFront){
@@ -7,7 +7,7 @@ import LA$ from 'utils/likeA$';
7
7
 
8
8
 
9
9
  const TimeDisplayPanel = function($container, api, data){
10
- const $root = LA$("#"+api.getContainerId());
10
+ const $root = LA$(api.getContainerElement());
11
11
  let panelManager = PanelManager();
12
12
 
13
13
  data.setFront = function(isFront){
@@ -14,7 +14,7 @@ import LA$ from 'utils/likeA$';
14
14
 
15
15
 
16
16
  const CaptionViewer = function($container, api, playerState){
17
- const $root = LA$("#"+api.getContainerId());
17
+ const $root = LA$(api.getContainerElement());
18
18
 
19
19
  const onRendered = function($container, $current, template){
20
20
  let isDisable = false;
@@ -5,7 +5,7 @@ import OvenTemplate from 'view/engine/OvenTemplate';
5
5
  import LA$ from 'utils/likeA$';
6
6
 
7
7
  const ContextPanel = function($container, api, position){
8
- const $root = LA$("#"+api.getContainerId());
8
+ const $root = LA$(api.getContainerElement());
9
9
 
10
10
  const onRendered = function($current, template){
11
11
  const panelWidth = $current.width();
@@ -30,7 +30,7 @@ import {
30
30
  import '../../stylesheet/ovenplayer.less';
31
31
 
32
32
  const View = function($container){
33
- let viewTemplate = "", controls = "", helper = "", $playerRoot, contextPanel = "", api = "", autoHideTimer = "", playerState = STATE_IDLE;
33
+ let viewTemplate = "", controls = "", helper = "", $playerRoot, contextPanel = "", api = null, autoHideTimer = "", playerState = STATE_IDLE;
34
34
  let isShiftPressed = false;
35
35
  let panelManager = PanelManager();
36
36
  let screenSize = "";
@@ -311,6 +311,14 @@ const View = function($container){
311
311
  that.setApi = (playerInstance) => {
312
312
  api = playerInstance;
313
313
 
314
+ api.getContainerElement = () => {
315
+ return $playerRoot.get();
316
+ };
317
+
318
+ api.getContainerId = () => {
319
+ return $playerRoot.get().id;
320
+ };
321
+
314
322
  api.on(READY, function(data) {
315
323
 
316
324
  if(!controls){
@@ -2,15 +2,15 @@
2
2
  * Created by hoho on 2018. 7. 20..
3
3
  */
4
4
 
5
- const ViewTemplate = function(uiText, id){
6
- return `<div class="ovenplayer op-wrapper" tabindex="-1" aria-label="" id="${id}">` +
7
- `<div class="op-ratio"></div>` +
8
- `<div class="op-player op-clear">`+
9
- `<div class="op-core-ui-wrapper op-clear">` +
10
- `<div class="op-media-element-container op-clear" data-parent-id="${id}"></div>` +
11
- `<div class="op-ui op-clear"></div>`+
5
+ const ViewTemplate = function (uiText, id) {
6
+ return `<div class="ovenplayer op-wrapper" tabindex="-1" ${id ? `id = "${id}"` : ``}>` +
7
+ `<div class="op-ratio"></div>` +
8
+ `<div class="op-player op-clear">` +
9
+ `<div class="op-core-ui-wrapper op-clear">` +
10
+ `<div class="op-media-element-container op-clear"></div>` +
11
+ `<div class="op-ui op-clear"></div>` +
12
+ `</div>` +
12
13
  `</div>` +
13
- `</div>` +
14
14
  `</div>`
15
15
  };
16
16
  export default ViewTemplate;
@@ -1354,6 +1354,7 @@ i.op-con{
1354
1354
  -webkit-transition: bottom .25s cubic-bezier(0.0,0.0,0.2,1);
1355
1355
  transition: bottom .25s cubic-bezier(0.0,0.0,0.2,1);
1356
1356
  .op-caption-text {
1357
+ color: #fff;
1357
1358
  font-size: 1em;
1358
1359
  line-height: 1.2em;
1359
1360
  text-shadow: 2px 2px 2px gray;