ovenplayer 0.10.49 → 0.10.51

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 (34) hide show
  1. package/dist/ovenplayer.js +1 -1
  2. package/dist/ovenplayer.js.map +1 -1
  3. package/package.json +49 -49
  4. package/src/js/api/Configurator.js +1 -1
  5. package/src/js/api/ads/vast/Ad.js +237 -237
  6. package/src/js/api/caption/Loader.js +1 -1
  7. package/src/js/api/caption/Manager.js +1 -1
  8. package/src/js/api/caption/parser/VttParser.js +1541 -1542
  9. package/src/js/api/playlist/Manager.js +229 -229
  10. package/src/js/api/provider/html5/providers/Dash.js +286 -286
  11. package/src/js/api/provider/html5/providers/Hls.js +110 -2
  12. package/src/js/api/provider/html5/providers/WebRTC.js +2 -1
  13. package/src/js/api/provider/html5/providers/WebRTCLoader.js +35 -2
  14. package/src/js/api/provider/utils.js +69 -69
  15. package/src/js/ovenplayer.sdk.js +143 -143
  16. package/src/js/utils/likeA$.js +241 -242
  17. package/src/js/utils/resize-sensor.js +145 -168
  18. package/src/js/utils/strings.js +104 -104
  19. package/src/js/view/components/controls/settingPanel/audioTrackPanel.js +57 -57
  20. package/src/js/view/components/controls/settingPanel/main.js +1 -1
  21. package/src/js/view/components/controls/settingPanel/mainTemplate.js +29 -29
  22. package/src/js/view/components/controls/settingPanel/qualityPanel.js +68 -68
  23. package/src/js/view/components/controls/settingPanel/subtitleTrackPanel.js +56 -56
  24. package/src/js/view/components/helpers/captionViewer.js +97 -15
  25. package/src/js/view/components/helpers/captionViewerTemplate.js +1 -2
  26. package/src/js/view/components/helpers/waterMark.js +69 -69
  27. package/src/js/view/engine/OvenTemplate.js +158 -158
  28. package/src/js/view/global/PanelManager.js +47 -47
  29. package/src/stylesheet/ovenplayer.less +52 -21
  30. package/src/js/utils/adapter.js +0 -4944
  31. package/src/js/utils/captions/vttCue.js +0 -308
  32. package/src/js/utils/captions/vttRegion.js +0 -136
  33. package/src/js/utils/polyfills/dom.js +0 -634
  34. package/src/js/utils/underscore.js +0 -6
@@ -1,286 +1,286 @@
1
- /**
2
- * Created by hoho on 2018. 6. 14..
3
- */
4
- import Provider from "api/provider/html5/Provider";
5
- import {errorTrigger} from "api/provider/utils";
6
- import sizeHumanizer from "utils/sizeHumanizer";
7
- import {
8
- STATE_IDLE,
9
- STATE_PLAYING,
10
- STATE_AD_PLAYING,
11
- STATE_AD_PAUSED,
12
- INIT_DASH_UNSUPPORT,
13
- INIT_DASH_FAIL,
14
- ERRORS,
15
- PLAYER_UNKNWON_NETWORK_ERROR,
16
- CONTENT_LEVEL_CHANGED,
17
- PROVIDER_DASH,
18
- DASH_PREPARED,
19
- DASH_DESTROYED
20
- } from "api/constants";
21
- import _ from "utils/underscore";
22
- import {STATE_LOADING} from "../../../constants";
23
-
24
- /**
25
- * @brief dashjs provider extended core.
26
- * @param container player element.
27
- * @param playerConfig config.
28
- * */
29
- const DASHERROR = {
30
- DOWNLOAD: "download",
31
- MANIFESTERROR: "manifestError"
32
- };
33
- const Dash = function (element, playerConfig, adTagUrl) {
34
-
35
- let that = {};
36
- let dash = null;
37
- let superPlay_func = null;
38
- let superDestroy_func = null;
39
- let seekPosition_sec = 0;
40
- let prevLLLiveDuration = null;
41
- let loadRetryer = null;
42
- let sourceOfFile = "";
43
-
44
- try {
45
-
46
- if (dashjs.Version < "3.0.0") {
47
- throw ERRORS.codes[INIT_DASH_UNSUPPORT];
48
- }
49
-
50
- const coveredSetAutoSwitchQualityFor = function (isAuto) {
51
-
52
- dash.updateSettings({
53
- streaming: {
54
- abr: {
55
- autoSwitchBitrate: {
56
- video: isAuto
57
- }
58
- }
59
- }
60
- });
61
- };
62
-
63
- const coveredGetAutoSwitchQualityFor = function () {
64
-
65
- return dash.getSettings().streaming.abr.autoSwitchBitrate.video;
66
- };
67
-
68
- const liveDelayReducingCallback = function () {
69
-
70
- if (dash.duration() !== prevLLLiveDuration) {
71
- prevLLLiveDuration = dash.duration();
72
-
73
- let dvrInfo = dash.getDashMetrics().getCurrentDVRInfo();
74
- let liveDelay = playerConfig.getConfig().lowLatencyMpdLiveDelay;
75
-
76
- if (!liveDelay) {
77
- liveDelay = 3;
78
- }
79
-
80
- dash.seek(dvrInfo.range.end - dvrInfo.range.start - liveDelay)
81
- }
82
-
83
- };
84
-
85
- dash = dashjs.MediaPlayer().create();
86
- dash.initialize(element, null, false);
87
-
88
- window.op_dash = dash;
89
-
90
- let spec = {
91
- name: PROVIDER_DASH,
92
- element: element,
93
- mse: dash,
94
- listener: null,
95
- isLoaded: false,
96
- canSeek: false,
97
- isLive: false,
98
- seeking: false,
99
- state: STATE_IDLE,
100
- buffer: 0,
101
- framerate: 0,
102
- currentQuality: -1,
103
- currentSource: -1,
104
- qualityLevels: [],
105
- sources: [],
106
- adTagUrl: adTagUrl
107
- };
108
-
109
- that = Provider(spec, playerConfig, function (source, lastPlayPosition) {
110
-
111
- OvenPlayerConsole.log("DASH : Attach File : ", source, "lastPlayPosition : " + lastPlayPosition);
112
-
113
- coveredSetAutoSwitchQualityFor(true);
114
- sourceOfFile = source.file;
115
-
116
- // dash.off(dashjs.MediaPlayer.events.PLAYBACK_PLAYING, liveDelayReducingCallback);
117
-
118
- if (source.lowLatency === true) {
119
-
120
- prevLLLiveDuration = null;
121
-
122
- dash.updateSettings({
123
- streaming: {
124
- lowLatencyEnabled: source.lowLatency
125
- }
126
- });
127
-
128
- if (playerConfig.getConfig().lowLatencyMpdLiveDelay && typeof(playerConfig.getConfig().lowLatencyMpdLiveDelay) === 'number') {
129
-
130
- dash.updateSettings({
131
- streaming: {
132
- liveDelay: playerConfig.getConfig().lowLatencyMpdLiveDelay
133
- }
134
- });
135
- }
136
-
137
- // dash.on(dashjs.MediaPlayer.events.PLAYBACK_PLAYING, liveDelayReducingCallback);
138
-
139
- } else {
140
-
141
- dash.updateSettings({
142
- streaming: {
143
- lowLatencyEnabled: false,
144
- liveDelay: undefined
145
- }
146
- });
147
-
148
- }
149
-
150
- dash.updateSettings({
151
- debug: {
152
- logLevel: dashjs.Debug.LOG_LEVEL_NONE
153
- }
154
- });
155
-
156
- let dashConfigFromPlayerConfig = playerConfig.getConfig().dashConfig;
157
-
158
- if (dashConfigFromPlayerConfig) {
159
- dash.updateSettings(dashConfigFromPlayerConfig);
160
- }
161
-
162
- that.trigger(DASH_PREPARED, dash);
163
-
164
- dash.attachSource(sourceOfFile);
165
-
166
- seekPosition_sec = lastPlayPosition;
167
- });
168
-
169
- superPlay_func = that.super('play');
170
- superDestroy_func = that.super('destroy');
171
- OvenPlayerConsole.log("DASH PROVIDER LOADED.");
172
-
173
- dash.on(dashjs.MediaPlayer.events.ERROR, function (error) {
174
-
175
- let tempError = ERRORS.codes[PLAYER_UNKNWON_NETWORK_ERROR];
176
- tempError.error = error;
177
- errorTrigger(tempError, that);
178
- });
179
-
180
- dash.on(dashjs.MediaPlayer.events.QUALITY_CHANGE_REQUESTED, function (event) {
181
- if (event && event.mediaType && event.mediaType === "video") {
182
- that.trigger(CONTENT_LEVEL_CHANGED, {
183
- isAuto: coveredGetAutoSwitchQualityFor(),
184
- currentQuality: spec.currentQuality,
185
- type: "request"
186
- });
187
- }
188
- });
189
- dash.on(dashjs.MediaPlayer.events.QUALITY_CHANGE_RENDERED, function (event) {
190
- if (event && event.mediaType && event.mediaType === "video") {
191
- spec.currentQuality = event.newQuality;
192
- that.trigger(CONTENT_LEVEL_CHANGED, {
193
- isAuto: coveredGetAutoSwitchQualityFor(),
194
- currentQuality: event.newQuality,
195
- type: "render"
196
- });
197
- }
198
- });
199
-
200
- dash.on(dashjs.MediaPlayer.events.PLAYBACK_METADATA_LOADED, function (event) {
201
-
202
- OvenPlayerConsole.log("DASH : PLAYBACK_METADATA_LOADED : ", dash.getQualityFor("video"), dash.getBitrateInfoListFor('video'), dash.getBitrateInfoListFor('video')[dash.getQualityFor("video")]);
203
-
204
- let subQualityList = dash.getBitrateInfoListFor('video');
205
- spec.currentQuality = dash.getQualityFor("video");
206
- for (let i = 0; i < subQualityList.length; i++) {
207
- if (!_.findWhere(spec.qualityLevels, {bitrate: subQualityList[i].bitrate, height: subQualityList[i].height, width: subQualityList[i].width})) {
208
- spec.qualityLevels.push({
209
- bitrate: subQualityList[i].bitrate,
210
- height: subQualityList[i].height,
211
- width: subQualityList[i].width,
212
- index: subQualityList[i].qualityIndex,
213
- label: subQualityList[i].width + "x" + subQualityList[i].height + ", " + sizeHumanizer(subQualityList[i].bitrate, true, "bps")
214
- });
215
- }
216
- }
217
-
218
- if (dash.isDynamic()) {
219
- spec.isLive = true;
220
- }
221
-
222
- if (seekPosition_sec && !spec.isLive) {
223
- dash.seek(seekPosition_sec);
224
- }
225
-
226
- });
227
-
228
- that.play = (mutedPlay) => {
229
-
230
- if (that.getState() === STATE_AD_PLAYING || that.getState() === STATE_AD_PAUSED) {
231
-
232
- } else {
233
-
234
- superPlay_func(mutedPlay);
235
- }
236
-
237
- };
238
-
239
- that.setCurrentQuality = (qualityIndex) => {
240
- if (that.getState() !== STATE_PLAYING) {
241
- that.play();
242
- }
243
- spec.currentQuality = qualityIndex;
244
- if (coveredGetAutoSwitchQualityFor()) {
245
- coveredSetAutoSwitchQualityFor(false);
246
- }
247
- dash.setQualityFor("video", qualityIndex);
248
- return spec.currentQuality;
249
- };
250
- that.isAutoQuality = () => {
251
- return coveredGetAutoSwitchQualityFor();
252
- };
253
- that.setAutoQuality = (isAuto) => {
254
- coveredSetAutoSwitchQualityFor(isAuto);
255
- };
256
- that.destroy = () => {
257
-
258
- if (dash.destroy) {
259
-
260
- dash.destroy();
261
- } else {
262
-
263
- dash.reset();
264
- }
265
-
266
- dash = null;
267
- that.trigger(DASH_DESTROYED);
268
- OvenPlayerConsole.log("DASH : PROVIDER DESTROYED.");
269
- superDestroy_func();
270
- };
271
- } catch (error) {
272
-
273
- if (error && error.code && error.code === INIT_DASH_UNSUPPORT) {
274
- throw error;
275
- } else {
276
- let tempError = ERRORS.codes[INIT_DASH_FAIL];
277
- tempError.error = error;
278
- throw tempError;
279
- }
280
- }
281
-
282
- return that;
283
- };
284
-
285
-
286
- export default Dash;
1
+ /**
2
+ * Created by hoho on 2018. 6. 14..
3
+ */
4
+ import Provider from "api/provider/html5/Provider";
5
+ import {errorTrigger} from "api/provider/utils";
6
+ import sizeHumanizer from "utils/sizeHumanizer";
7
+ import {
8
+ STATE_IDLE,
9
+ STATE_PLAYING,
10
+ STATE_AD_PLAYING,
11
+ STATE_AD_PAUSED,
12
+ INIT_DASH_UNSUPPORT,
13
+ INIT_DASH_FAIL,
14
+ ERRORS,
15
+ PLAYER_UNKNWON_NETWORK_ERROR,
16
+ CONTENT_LEVEL_CHANGED,
17
+ PROVIDER_DASH,
18
+ DASH_PREPARED,
19
+ DASH_DESTROYED
20
+ } from "api/constants";
21
+ import _ from "underscore";
22
+ import {STATE_LOADING} from "../../../constants";
23
+
24
+ /**
25
+ * @brief dashjs provider extended core.
26
+ * @param container player element.
27
+ * @param playerConfig config.
28
+ * */
29
+ const DASHERROR = {
30
+ DOWNLOAD: "download",
31
+ MANIFESTERROR: "manifestError"
32
+ };
33
+ const Dash = function (element, playerConfig, adTagUrl) {
34
+
35
+ let that = {};
36
+ let dash = null;
37
+ let superPlay_func = null;
38
+ let superDestroy_func = null;
39
+ let seekPosition_sec = 0;
40
+ let prevLLLiveDuration = null;
41
+ let loadRetryer = null;
42
+ let sourceOfFile = "";
43
+
44
+ try {
45
+
46
+ if (dashjs.Version < "3.0.0") {
47
+ throw ERRORS.codes[INIT_DASH_UNSUPPORT];
48
+ }
49
+
50
+ const coveredSetAutoSwitchQualityFor = function (isAuto) {
51
+
52
+ dash.updateSettings({
53
+ streaming: {
54
+ abr: {
55
+ autoSwitchBitrate: {
56
+ video: isAuto
57
+ }
58
+ }
59
+ }
60
+ });
61
+ };
62
+
63
+ const coveredGetAutoSwitchQualityFor = function () {
64
+
65
+ return dash.getSettings().streaming.abr.autoSwitchBitrate.video;
66
+ };
67
+
68
+ const liveDelayReducingCallback = function () {
69
+
70
+ if (dash.duration() !== prevLLLiveDuration) {
71
+ prevLLLiveDuration = dash.duration();
72
+
73
+ let dvrInfo = dash.getDashMetrics().getCurrentDVRInfo();
74
+ let liveDelay = playerConfig.getConfig().lowLatencyMpdLiveDelay;
75
+
76
+ if (!liveDelay) {
77
+ liveDelay = 3;
78
+ }
79
+
80
+ dash.seek(dvrInfo.range.end - dvrInfo.range.start - liveDelay)
81
+ }
82
+
83
+ };
84
+
85
+ dash = dashjs.MediaPlayer().create();
86
+ dash.initialize(element, null, false);
87
+
88
+ window.op_dash = dash;
89
+
90
+ let spec = {
91
+ name: PROVIDER_DASH,
92
+ element: element,
93
+ mse: dash,
94
+ listener: null,
95
+ isLoaded: false,
96
+ canSeek: false,
97
+ isLive: false,
98
+ seeking: false,
99
+ state: STATE_IDLE,
100
+ buffer: 0,
101
+ framerate: 0,
102
+ currentQuality: -1,
103
+ currentSource: -1,
104
+ qualityLevels: [],
105
+ sources: [],
106
+ adTagUrl: adTagUrl
107
+ };
108
+
109
+ that = Provider(spec, playerConfig, function (source, lastPlayPosition) {
110
+
111
+ OvenPlayerConsole.log("DASH : Attach File : ", source, "lastPlayPosition : " + lastPlayPosition);
112
+
113
+ coveredSetAutoSwitchQualityFor(true);
114
+ sourceOfFile = source.file;
115
+
116
+ // dash.off(dashjs.MediaPlayer.events.PLAYBACK_PLAYING, liveDelayReducingCallback);
117
+
118
+ if (source.lowLatency === true) {
119
+
120
+ prevLLLiveDuration = null;
121
+
122
+ dash.updateSettings({
123
+ streaming: {
124
+ lowLatencyEnabled: source.lowLatency
125
+ }
126
+ });
127
+
128
+ if (playerConfig.getConfig().lowLatencyMpdLiveDelay && typeof(playerConfig.getConfig().lowLatencyMpdLiveDelay) === 'number') {
129
+
130
+ dash.updateSettings({
131
+ streaming: {
132
+ liveDelay: playerConfig.getConfig().lowLatencyMpdLiveDelay
133
+ }
134
+ });
135
+ }
136
+
137
+ // dash.on(dashjs.MediaPlayer.events.PLAYBACK_PLAYING, liveDelayReducingCallback);
138
+
139
+ } else {
140
+
141
+ dash.updateSettings({
142
+ streaming: {
143
+ lowLatencyEnabled: false,
144
+ liveDelay: undefined
145
+ }
146
+ });
147
+
148
+ }
149
+
150
+ dash.updateSettings({
151
+ debug: {
152
+ logLevel: dashjs.Debug.LOG_LEVEL_NONE
153
+ }
154
+ });
155
+
156
+ let dashConfigFromPlayerConfig = playerConfig.getConfig().dashConfig;
157
+
158
+ if (dashConfigFromPlayerConfig) {
159
+ dash.updateSettings(dashConfigFromPlayerConfig);
160
+ }
161
+
162
+ that.trigger(DASH_PREPARED, dash);
163
+
164
+ dash.attachSource(sourceOfFile);
165
+
166
+ seekPosition_sec = lastPlayPosition;
167
+ });
168
+
169
+ superPlay_func = that.super('play');
170
+ superDestroy_func = that.super('destroy');
171
+ OvenPlayerConsole.log("DASH PROVIDER LOADED.");
172
+
173
+ dash.on(dashjs.MediaPlayer.events.ERROR, function (error) {
174
+
175
+ let tempError = ERRORS.codes[PLAYER_UNKNWON_NETWORK_ERROR];
176
+ tempError.error = error;
177
+ errorTrigger(tempError, that);
178
+ });
179
+
180
+ dash.on(dashjs.MediaPlayer.events.QUALITY_CHANGE_REQUESTED, function (event) {
181
+ if (event && event.mediaType && event.mediaType === "video") {
182
+ that.trigger(CONTENT_LEVEL_CHANGED, {
183
+ isAuto: coveredGetAutoSwitchQualityFor(),
184
+ currentQuality: spec.currentQuality,
185
+ type: "request"
186
+ });
187
+ }
188
+ });
189
+ dash.on(dashjs.MediaPlayer.events.QUALITY_CHANGE_RENDERED, function (event) {
190
+ if (event && event.mediaType && event.mediaType === "video") {
191
+ spec.currentQuality = event.newQuality;
192
+ that.trigger(CONTENT_LEVEL_CHANGED, {
193
+ isAuto: coveredGetAutoSwitchQualityFor(),
194
+ currentQuality: event.newQuality,
195
+ type: "render"
196
+ });
197
+ }
198
+ });
199
+
200
+ dash.on(dashjs.MediaPlayer.events.PLAYBACK_METADATA_LOADED, function (event) {
201
+
202
+ OvenPlayerConsole.log("DASH : PLAYBACK_METADATA_LOADED : ", dash.getQualityFor("video"), dash.getBitrateInfoListFor('video'), dash.getBitrateInfoListFor('video')[dash.getQualityFor("video")]);
203
+
204
+ let subQualityList = dash.getBitrateInfoListFor('video');
205
+ spec.currentQuality = dash.getQualityFor("video");
206
+ for (let i = 0; i < subQualityList.length; i++) {
207
+ if (!_.findWhere(spec.qualityLevels, {bitrate: subQualityList[i].bitrate, height: subQualityList[i].height, width: subQualityList[i].width})) {
208
+ spec.qualityLevels.push({
209
+ bitrate: subQualityList[i].bitrate,
210
+ height: subQualityList[i].height,
211
+ width: subQualityList[i].width,
212
+ index: subQualityList[i].qualityIndex,
213
+ label: subQualityList[i].width + "x" + subQualityList[i].height + ", " + sizeHumanizer(subQualityList[i].bitrate, true, "bps")
214
+ });
215
+ }
216
+ }
217
+
218
+ if (dash.isDynamic()) {
219
+ spec.isLive = true;
220
+ }
221
+
222
+ if (seekPosition_sec && !spec.isLive) {
223
+ dash.seek(seekPosition_sec);
224
+ }
225
+
226
+ });
227
+
228
+ that.play = (mutedPlay) => {
229
+
230
+ if (that.getState() === STATE_AD_PLAYING || that.getState() === STATE_AD_PAUSED) {
231
+
232
+ } else {
233
+
234
+ superPlay_func(mutedPlay);
235
+ }
236
+
237
+ };
238
+
239
+ that.setCurrentQuality = (qualityIndex) => {
240
+ if (that.getState() !== STATE_PLAYING) {
241
+ that.play();
242
+ }
243
+ spec.currentQuality = qualityIndex;
244
+ if (coveredGetAutoSwitchQualityFor()) {
245
+ coveredSetAutoSwitchQualityFor(false);
246
+ }
247
+ dash.setQualityFor("video", qualityIndex);
248
+ return spec.currentQuality;
249
+ };
250
+ that.isAutoQuality = () => {
251
+ return coveredGetAutoSwitchQualityFor();
252
+ };
253
+ that.setAutoQuality = (isAuto) => {
254
+ coveredSetAutoSwitchQualityFor(isAuto);
255
+ };
256
+ that.destroy = () => {
257
+
258
+ if (dash.destroy) {
259
+
260
+ dash.destroy();
261
+ } else {
262
+
263
+ dash.reset();
264
+ }
265
+
266
+ dash = null;
267
+ that.trigger(DASH_DESTROYED);
268
+ OvenPlayerConsole.log("DASH : PROVIDER DESTROYED.");
269
+ superDestroy_func();
270
+ };
271
+ } catch (error) {
272
+
273
+ if (error && error.code && error.code === INIT_DASH_UNSUPPORT) {
274
+ throw error;
275
+ } else {
276
+ let tempError = ERRORS.codes[INIT_DASH_FAIL];
277
+ tempError.error = error;
278
+ throw tempError;
279
+ }
280
+ }
281
+
282
+ return that;
283
+ };
284
+
285
+
286
+ export default Dash;