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.
- package/LICENSE +1 -1
- package/README.md +39 -46
- package/dist/ovenplayer.js +1 -1
- package/dist/ovenplayer.js.map +1 -1
- package/package.json +1 -1
- package/src/assets/fonts/seek-icons.svg +13 -13
- package/src/js/api/Api.js +231 -140
- package/src/js/api/Configurator.js +6 -3
- package/src/js/api/SupportChecker.js +9 -3
- package/src/js/api/constants.js +203 -15
- package/src/js/api/media/Manager.js +15 -106
- package/src/js/api/provider/Controller.js +5 -6
- package/src/js/api/provider/html5/Provider.js +107 -86
- package/src/js/api/provider/html5/providers/Dash.js +39 -110
- package/src/js/api/provider/html5/providers/Hls.js +139 -99
- package/src/js/api/provider/html5/providers/Html5.js +3 -1
- package/src/js/api/provider/html5/providers/WebRTC.js +207 -37
- package/src/js/api/provider/html5/providers/WebRTCLoader.js +247 -116
- package/src/js/ovenplayer.js +5 -9
- package/src/js/ovenplayer.sdk.js +5 -6
- package/src/js/utils/browser.js +6 -1
- package/src/js/utils/getTouchSection.js +23 -0
- package/src/js/utils/likeA$.js +4 -3
- package/src/js/utils/resize-sensor.js +168 -1
- package/src/js/utils/underscore.js +5 -5
- package/src/js/view/components/controls/fullScreenButton.js +22 -15
- package/src/js/view/components/controls/main.js +33 -20
- package/src/js/view/components/controls/playlistPanel.js +1 -1
- package/src/js/view/components/controls/progressBar.js +151 -76
- package/src/js/view/components/controls/settingButton.js +65 -48
- package/src/js/view/components/controls/settingPanel/audioTrackPanel.js +57 -0
- package/src/js/view/components/controls/settingPanel/captionPanel.js +1 -1
- package/src/js/view/components/controls/settingPanel/main.js +110 -80
- package/src/js/view/components/controls/settingPanel/qualityPanel.js +2 -2
- package/src/js/view/components/controls/settingPanel/sourcePanel.js +1 -1
- package/src/js/view/components/controls/settingPanel/speedPanel.js +1 -1
- package/src/js/view/components/controls/settingPanel/timeDisplayPanel.js +1 -1
- package/src/js/view/components/controls/timeDisplay.js +95 -23
- package/src/js/view/components/controls/timeDisplayTemplate.js +1 -1
- package/src/js/view/components/controls/volumeButton.js +2 -3
- package/src/js/view/components/helpers/captionViewer.js +1 -1
- package/src/js/view/components/helpers/contextPanel.js +1 -1
- package/src/js/view/components/helpers/contextPanelTemplate.js +1 -1
- package/src/js/view/components/helpers/main.js +21 -0
- package/src/js/view/components/helpers/thumbnailTemplate.js +0 -1
- package/src/js/view/engine/Templates.js +2 -0
- package/src/js/view/view.js +53 -14
- package/src/js/view/viewTemplate.js +8 -8
- package/src/stylesheet/ovenplayer.less +565 -308
|
@@ -3,17 +3,18 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import OvenTemplate from "view/engine/OvenTemplate";
|
|
5
5
|
import PanelManager from "view/global/PanelManager";
|
|
6
|
-
import {naturalHms} from "utils/strings"
|
|
6
|
+
import { naturalHms } from "utils/strings"
|
|
7
7
|
import LA$ from "utils/likeA$";
|
|
8
8
|
import {
|
|
9
9
|
CONTENT_TIME,
|
|
10
10
|
CONTENT_BUFFER,
|
|
11
|
-
AD_TIME
|
|
11
|
+
AD_TIME,
|
|
12
|
+
PROVIDER_HLS,
|
|
13
|
+
PROVIDER_HTML5
|
|
12
14
|
} from "api/constants";
|
|
13
|
-
import {STATE_COMPLETE} from "../../../api/constants";
|
|
14
15
|
|
|
15
|
-
const ProgressBar = function($container, api, isAd){
|
|
16
|
-
const $root = LA$(
|
|
16
|
+
const ProgressBar = function ($container, api, isAd, metadata) {
|
|
17
|
+
const $root = LA$(api.getContainerElement());
|
|
17
18
|
|
|
18
19
|
if (api.getConfig().disableSeekUI) {
|
|
19
20
|
$container.addClass('op-progressbar-container-disabled');
|
|
@@ -41,16 +42,29 @@ const ProgressBar = function($container, api, isAd){
|
|
|
41
42
|
|
|
42
43
|
let isMobile = api.getBrowser().mobile;
|
|
43
44
|
|
|
45
|
+
const mediaElement = api.getMediaElement();
|
|
46
|
+
|
|
47
|
+
let hlsLive = false;
|
|
48
|
+
let nativeHlsLive = false;
|
|
49
|
+
|
|
50
|
+
if (metadata && metadata.type === PROVIDER_HLS && metadata.duration === Infinity) {
|
|
51
|
+
hlsLive = true;
|
|
52
|
+
|
|
53
|
+
if (api.getProviderName() === PROVIDER_HTML5) {
|
|
54
|
+
nativeHlsLive = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
44
58
|
function positionElements(percentage) {
|
|
45
59
|
|
|
46
60
|
let progressBarWidth = $progressBar.width();
|
|
47
61
|
let position = progressBarWidth * percentage;
|
|
48
62
|
|
|
49
|
-
$progressPlay.css("width", position+ "px");
|
|
50
|
-
$progressHover.css("left", position+ "px");
|
|
63
|
+
$progressPlay.css("width", position + "px");
|
|
64
|
+
$progressHover.css("left", position + "px");
|
|
51
65
|
|
|
52
66
|
let knobPostion = (progressBarWidth - knobWidth) * percentage;
|
|
53
|
-
$knobContainer.css("left", knobPostion+ "px");
|
|
67
|
+
$knobContainer.css("left", knobPostion + "px");
|
|
54
68
|
|
|
55
69
|
currentPlayingPosition = position;
|
|
56
70
|
currentPlayingPercentage = percentage;
|
|
@@ -60,7 +74,7 @@ const ProgressBar = function($container, api, isAd){
|
|
|
60
74
|
|
|
61
75
|
let progressBarWidth = $progressBar.width();
|
|
62
76
|
let hoverPosition = progressBarWidth * percentage;
|
|
63
|
-
$progressHover.css("width", (percentage === 0 ? percentage : (hoverPosition - currentPlayingPosition))+ "px");
|
|
77
|
+
$progressHover.css("width", (percentage === 0 ? percentage : (hoverPosition - currentPlayingPosition)) + "px");
|
|
64
78
|
|
|
65
79
|
}
|
|
66
80
|
|
|
@@ -69,7 +83,7 @@ const ProgressBar = function($container, api, isAd){
|
|
|
69
83
|
let progressBarWidth = $progressBar.width();
|
|
70
84
|
let loadPosition = progressBarWidth * percentage;
|
|
71
85
|
|
|
72
|
-
$progressLoad.css("width", loadPosition+ "px");
|
|
86
|
+
$progressLoad.css("width", loadPosition + "px");
|
|
73
87
|
currentLoadedPercentage = percentage;
|
|
74
88
|
}
|
|
75
89
|
|
|
@@ -78,11 +92,11 @@ const ProgressBar = function($container, api, isAd){
|
|
|
78
92
|
let progressBarWidth = $progressBar.width();
|
|
79
93
|
let progressBarOffsetX = $progressBar.offset().left;
|
|
80
94
|
|
|
81
|
-
let pointerOffsetX =
|
|
95
|
+
let pointerOffsetX = event.pageX;
|
|
82
96
|
|
|
83
97
|
if (event.touches) {
|
|
84
98
|
|
|
85
|
-
pointerOffsetX =
|
|
99
|
+
pointerOffsetX = (event.pageX || event.touches[0].clientX);
|
|
86
100
|
}
|
|
87
101
|
|
|
88
102
|
let percentage = (pointerOffsetX - progressBarOffsetX) / progressBarWidth;
|
|
@@ -98,53 +112,73 @@ const ProgressBar = function($container, api, isAd){
|
|
|
98
112
|
return percentage;
|
|
99
113
|
}
|
|
100
114
|
|
|
115
|
+
function getNativeHlsDvrWindow() {
|
|
116
|
+
return mediaElement.seekable.end(mediaElement.seekable.length - 1) - mediaElement.seekable.start(0);
|
|
117
|
+
}
|
|
118
|
+
|
|
101
119
|
function drawTimeIndicator(percentage, event) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
//const duration = isAd ? adDuration : api.getDuration();
|
|
112
|
-
let duration = api.getDuration();
|
|
113
|
-
let second = duration * percentage;
|
|
114
|
-
|
|
115
|
-
if(api.isTimecodeMode()){
|
|
116
|
-
$time.text(naturalHms(second));
|
|
117
|
-
}else{
|
|
118
|
-
$time.text(Math.round (second * api.getFramerate()));
|
|
120
|
+
if (panelManager.size() > 0 || percentage === -1) {
|
|
121
|
+
$time.hide();
|
|
122
|
+
$preview.hide();
|
|
123
|
+
return;
|
|
124
|
+
} else {
|
|
125
|
+
$time.show();
|
|
126
|
+
$preview.show();
|
|
119
127
|
}
|
|
120
128
|
|
|
129
|
+
if (hlsLive && !nativeHlsLive) {
|
|
121
130
|
|
|
131
|
+
let duration = api.getDvrWindow();
|
|
132
|
+
let second = duration * (1 - percentage);
|
|
133
|
+
if (api.isTimecodeMode()) {
|
|
134
|
+
$time.text('- ' + naturalHms(second));
|
|
135
|
+
} else {
|
|
136
|
+
$time.text('- ' + Math.round(second * api.getFramerate()));
|
|
137
|
+
}
|
|
138
|
+
} else if (hlsLive && nativeHlsLive) {
|
|
139
|
+
|
|
140
|
+
let duration = getNativeHlsDvrWindow();
|
|
141
|
+
let second = duration * (1 - percentage);
|
|
142
|
+
if (api.isTimecodeMode()) {
|
|
143
|
+
$time.text('- ' + naturalHms(second));
|
|
144
|
+
} else {
|
|
145
|
+
$time.text('- ' + Math.round(second * api.getFramerate()));
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
|
|
149
|
+
let duration = api.getDuration();
|
|
150
|
+
let second = duration * percentage;
|
|
151
|
+
|
|
152
|
+
if (api.isTimecodeMode()) {
|
|
153
|
+
$time.text(naturalHms(second));
|
|
154
|
+
} else {
|
|
155
|
+
$time.text(Math.round(second * api.getFramerate()));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
122
158
|
|
|
123
159
|
let timeElemWidth = $time.width();
|
|
124
160
|
let progressBarWidth = $progressBar.width();
|
|
125
161
|
let position = progressBarWidth * percentage;
|
|
126
162
|
|
|
127
|
-
let positionOfPixel =
|
|
163
|
+
let positionOfPixel = event.pageX - $progressBar.offset().left;
|
|
128
164
|
|
|
129
165
|
if (event.touches) {
|
|
130
|
-
positionOfPixel =
|
|
166
|
+
positionOfPixel = (event.pageX || event.touches[0].clientX) - $progressBar.offset().left;
|
|
131
167
|
}
|
|
132
168
|
|
|
133
169
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if(positionOfPixel < elementWidth / 2){
|
|
170
|
+
const calculateMagnetic = function (elementWidth) {
|
|
171
|
+
if (positionOfPixel < elementWidth / 2) {
|
|
137
172
|
return 0;
|
|
138
|
-
}else if(progressBarWidth-positionOfPixel
|
|
173
|
+
} else if (progressBarWidth - positionOfPixel < elementWidth / 2) {
|
|
139
174
|
return progressBarWidth - elementWidth;
|
|
140
|
-
}else{
|
|
175
|
+
} else {
|
|
141
176
|
return position - elementWidth / 2;
|
|
142
177
|
}
|
|
143
178
|
};
|
|
144
179
|
|
|
145
180
|
let magneticPosition = calculateMagnetic(timeElemWidth);
|
|
146
|
-
$time.css("left", magneticPosition+ "px");
|
|
147
|
-
|
|
181
|
+
$time.css("left", magneticPosition + "px");
|
|
148
182
|
|
|
149
183
|
if (api.getSources()[api.getCurrentSource()].gridThumbnail) {
|
|
150
184
|
|
|
@@ -167,23 +201,23 @@ const ProgressBar = function($container, api, isAd){
|
|
|
167
201
|
let columnNumber = (thumbnailNumber % (columnCount * rowCount)) % columnCount;
|
|
168
202
|
|
|
169
203
|
let left = -1 * columnNumber * width * scale;
|
|
170
|
-
let top =
|
|
204
|
+
let top = -1 * rowNumber * height * scale;
|
|
171
205
|
|
|
172
|
-
OvenPlayerConsole.log('Grid Thumbnail:', thumbnailNumber + ': ' + imageNumber +'('+ rowNumber +', ' + columnNumber + ')');
|
|
206
|
+
OvenPlayerConsole.log('Grid Thumbnail:', thumbnailNumber + ': ' + imageNumber + '(' + rowNumber + ', ' + columnNumber + ')');
|
|
173
207
|
|
|
174
208
|
let thumbnails = api.getSources()[api.getCurrentSource()].gridThumbnail;
|
|
175
209
|
let thumbnail = thumbnails[imageNumber];
|
|
176
210
|
|
|
177
211
|
if (lastGridThumbnail !== thumbnail) {
|
|
178
212
|
|
|
179
|
-
$preview.css('background-image', 'url(' + thumbnail +')');
|
|
213
|
+
$preview.css('background-image', 'url(' + thumbnail + ')');
|
|
180
214
|
lastGridThumbnail = thumbnail;
|
|
181
215
|
}
|
|
182
216
|
|
|
183
217
|
$preview.css('background-position', 'left ' + left + 'px top ' + top + 'px');
|
|
184
218
|
|
|
185
219
|
let previewMagneticPosition = calculateMagnetic(width * scale);
|
|
186
|
-
$preview.css("left", previewMagneticPosition+ "px");
|
|
220
|
+
$preview.css("left", previewMagneticPosition + "px");
|
|
187
221
|
} else {
|
|
188
222
|
|
|
189
223
|
$preview.hide();
|
|
@@ -192,7 +226,34 @@ const ProgressBar = function($container, api, isAd){
|
|
|
192
226
|
|
|
193
227
|
function seek(percentage) {
|
|
194
228
|
|
|
195
|
-
let time = (durationForCalc||0) * percentage;
|
|
229
|
+
let time = (durationForCalc || 0) * percentage;
|
|
230
|
+
|
|
231
|
+
if (hlsLive && !nativeHlsLive) {
|
|
232
|
+
|
|
233
|
+
// if latency control is on. temporarily disable latency control
|
|
234
|
+
const config = api.getConfig();
|
|
235
|
+
if (config.hlsConfig) {
|
|
236
|
+
|
|
237
|
+
if (typeof config.hlsConfig.liveSyncDuration === 'number') {
|
|
238
|
+
api.getMseInstance().config.liveSyncDuration = undefined;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (typeof config.hlsConfig.liveMaxLatencyDuration === 'number') {
|
|
242
|
+
api.getMseInstance().config.liveMaxLatencyDuration = undefined;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (typeof config.hlsConfig.maxLiveSyncPlaybackRate === 'number') {
|
|
246
|
+
api.getMseInstance().config.maxLiveSyncPlaybackRate = 1;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
time = (durationForCalc - api.getDvrWindow()) + api.getDvrWindow() * percentage;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (hlsLive && nativeHlsLive) {
|
|
254
|
+
const dvrWindow = getNativeHlsDvrWindow();
|
|
255
|
+
time = (durationForCalc - dvrWindow) + dvrWindow * percentage;
|
|
256
|
+
}
|
|
196
257
|
|
|
197
258
|
let sectionStart = api.getSources()[api.getCurrentSource()].sectionStart;
|
|
198
259
|
|
|
@@ -204,7 +265,7 @@ const ProgressBar = function($container, api, isAd){
|
|
|
204
265
|
}
|
|
205
266
|
|
|
206
267
|
|
|
207
|
-
const onRendered = function($current, template){
|
|
268
|
+
const onRendered = function ($current, template) {
|
|
208
269
|
|
|
209
270
|
$progressBar = $current;
|
|
210
271
|
$progressLoad = $current.find(".op-load-progress");
|
|
@@ -216,44 +277,57 @@ const ProgressBar = function($container, api, isAd){
|
|
|
216
277
|
$time = $current.find(".op-progressbar-time");
|
|
217
278
|
$preview = $current.find(".op-progressbar-preview");
|
|
218
279
|
|
|
219
|
-
if(isAd){
|
|
220
|
-
api.on(AD_TIME, function(data) {
|
|
221
|
-
if(data && data.duration && data.position){
|
|
280
|
+
if (isAd) {
|
|
281
|
+
api.on(AD_TIME, function (data) {
|
|
282
|
+
if (data && data.duration && data.position) {
|
|
222
283
|
positionElements(data.position / data.duration);
|
|
223
284
|
adDuration = data.duration;
|
|
224
285
|
}
|
|
225
|
-
},template);
|
|
226
|
-
}else{
|
|
286
|
+
}, template);
|
|
287
|
+
} else {
|
|
288
|
+
|
|
289
|
+
api.on(CONTENT_TIME, function (data) {
|
|
290
|
+
if (data && data.duration && data.position) {
|
|
227
291
|
|
|
228
|
-
api.on(CONTENT_TIME, function(data) {
|
|
229
|
-
if(data && data.duration && data.position){
|
|
230
292
|
durationForCalc = data.duration;
|
|
231
|
-
|
|
293
|
+
let percentage = data.position / data.duration;
|
|
294
|
+
|
|
295
|
+
if (hlsLive && !nativeHlsLive) {
|
|
296
|
+
percentage = (api.getDvrWindow() - (data.duration - data.position)) / api.getDvrWindow();
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (hlsLive && nativeHlsLive) {
|
|
300
|
+
const dvrWindow = getNativeHlsDvrWindow();
|
|
301
|
+
durationForCalc = dvrWindow;
|
|
302
|
+
const position = Math.min(dvrWindow, data.position);
|
|
303
|
+
percentage = (dvrWindow - (dvrWindow - position)) / dvrWindow;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
positionElements(percentage);
|
|
232
307
|
}
|
|
233
|
-
},template);
|
|
308
|
+
}, template);
|
|
234
309
|
|
|
235
|
-
api.on(CONTENT_BUFFER, function(data) {
|
|
236
|
-
if(data && data.bufferPercent){
|
|
310
|
+
api.on(CONTENT_BUFFER, function (data) {
|
|
311
|
+
if (data && data.bufferPercent) {
|
|
237
312
|
drawLoadProgress(data.bufferPercent / 100);
|
|
238
313
|
}
|
|
239
|
-
},template);
|
|
314
|
+
}, template);
|
|
240
315
|
}
|
|
241
316
|
|
|
242
317
|
|
|
243
|
-
|
|
244
318
|
};
|
|
245
|
-
const onDestroyed = function(template){
|
|
246
|
-
if(isAd){
|
|
319
|
+
const onDestroyed = function (template) {
|
|
320
|
+
if (isAd) {
|
|
247
321
|
api.off(AD_TIME, null, template);
|
|
248
|
-
}else{
|
|
322
|
+
} else {
|
|
249
323
|
api.off(CONTENT_TIME, null, template);
|
|
250
324
|
api.off(CONTENT_BUFFER, null, template);
|
|
251
325
|
}
|
|
252
326
|
};
|
|
253
327
|
let events = {
|
|
254
|
-
"touchstart .op-progressbar"
|
|
328
|
+
"touchstart .op-progressbar": function (event) {
|
|
255
329
|
|
|
256
|
-
if(isAd){
|
|
330
|
+
if (isAd) {
|
|
257
331
|
return false;
|
|
258
332
|
}
|
|
259
333
|
mouseDown = true;
|
|
@@ -267,12 +341,12 @@ const ProgressBar = function($container, api, isAd){
|
|
|
267
341
|
drawHoverProgress(0);
|
|
268
342
|
seek(percentage);
|
|
269
343
|
},
|
|
270
|
-
"touchmove .op-progressbar"
|
|
344
|
+
"touchmove .op-progressbar": function (event) {
|
|
271
345
|
|
|
272
346
|
if (mouseDown) {
|
|
273
347
|
const percentage = calculatePercentage(event);
|
|
274
348
|
|
|
275
|
-
|
|
349
|
+
if (percentage === -1) {
|
|
276
350
|
return false;
|
|
277
351
|
}
|
|
278
352
|
|
|
@@ -282,9 +356,9 @@ const ProgressBar = function($container, api, isAd){
|
|
|
282
356
|
drawTimeIndicator(percentage, event);
|
|
283
357
|
}
|
|
284
358
|
},
|
|
285
|
-
"touchend .op-progressbar"
|
|
359
|
+
"touchend .op-progressbar": function (event) {
|
|
286
360
|
|
|
287
|
-
if(mouseDown){
|
|
361
|
+
if (mouseDown) {
|
|
288
362
|
mouseDown = false;
|
|
289
363
|
}
|
|
290
364
|
|
|
@@ -293,23 +367,24 @@ const ProgressBar = function($container, api, isAd){
|
|
|
293
367
|
$preview.hide();
|
|
294
368
|
|
|
295
369
|
},
|
|
296
|
-
"mouseenter .op-progressbar"
|
|
370
|
+
"mouseenter .op-progressbar": function (event, $current, template) {
|
|
297
371
|
|
|
298
372
|
event.preventDefault();
|
|
299
373
|
|
|
300
|
-
if(!isMobile){
|
|
301
|
-
if(!isAd){
|
|
374
|
+
if (!isMobile) {
|
|
375
|
+
if (!isAd) {
|
|
302
376
|
mouseInside = true;
|
|
303
377
|
$time.show();
|
|
304
378
|
}
|
|
305
379
|
$root.addClass("op-progressbar-hover");
|
|
306
380
|
}
|
|
307
381
|
},
|
|
308
|
-
"mouseleave .op-progressbar"
|
|
382
|
+
"mouseleave .op-progressbar": function (event, $current, template) {
|
|
309
383
|
|
|
310
384
|
event.preventDefault();
|
|
311
385
|
|
|
312
386
|
mouseInside = false;
|
|
387
|
+
mouseDown = false;
|
|
313
388
|
|
|
314
389
|
if (!mouseInside) {
|
|
315
390
|
$root.removeClass("op-progressbar-hover");
|
|
@@ -318,11 +393,11 @@ const ProgressBar = function($container, api, isAd){
|
|
|
318
393
|
}
|
|
319
394
|
drawHoverProgress(0);
|
|
320
395
|
},
|
|
321
|
-
"mousedown .op-progressbar"
|
|
396
|
+
"mousedown .op-progressbar": function (event, $current, template) {
|
|
322
397
|
|
|
323
398
|
event.preventDefault();
|
|
324
399
|
|
|
325
|
-
if(isAd || isMobile){
|
|
400
|
+
if (isAd || isMobile) {
|
|
326
401
|
return false;
|
|
327
402
|
}
|
|
328
403
|
|
|
@@ -337,7 +412,7 @@ const ProgressBar = function($container, api, isAd){
|
|
|
337
412
|
drawHoverProgress(0);
|
|
338
413
|
seek(percentage);
|
|
339
414
|
},
|
|
340
|
-
"mousemove .op-progressbar"
|
|
415
|
+
"mousemove .op-progressbar": function (event, $current, template) {
|
|
341
416
|
|
|
342
417
|
event.preventDefault();
|
|
343
418
|
|
|
@@ -359,11 +434,11 @@ const ProgressBar = function($container, api, isAd){
|
|
|
359
434
|
drawTimeIndicator(percentage, event);
|
|
360
435
|
}
|
|
361
436
|
},
|
|
362
|
-
"mouseup .op-progressbar"
|
|
437
|
+
"mouseup .op-progressbar": function (event, $current, template) {
|
|
363
438
|
|
|
364
439
|
event.preventDefault();
|
|
365
440
|
|
|
366
|
-
if(mouseDown && !isMobile){
|
|
441
|
+
if (mouseDown && !isMobile) {
|
|
367
442
|
mouseDown = false;
|
|
368
443
|
$root.removeClass("op-progressbar-hover");
|
|
369
444
|
}
|
|
@@ -375,7 +450,7 @@ const ProgressBar = function($container, api, isAd){
|
|
|
375
450
|
events = {}
|
|
376
451
|
}
|
|
377
452
|
|
|
378
|
-
return OvenTemplate($container, "ProgressBar", api.getConfig(), null, events, onRendered, onDestroyed
|
|
453
|
+
return OvenTemplate($container, "ProgressBar", api.getConfig(), null, events, onRendered, onDestroyed);
|
|
379
454
|
};
|
|
380
455
|
|
|
381
456
|
export default ProgressBar;
|
|
@@ -9,28 +9,29 @@ import {
|
|
|
9
9
|
} from "api/constants";
|
|
10
10
|
|
|
11
11
|
let PANEL_TITLE = {
|
|
12
|
-
"speed"
|
|
13
|
-
"speedUnit"
|
|
14
|
-
"source"
|
|
15
|
-
"quality"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
12
|
+
"speed": "Speed",
|
|
13
|
+
"speedUnit": "x",
|
|
14
|
+
"source": "Source",
|
|
15
|
+
"quality": "Quality",
|
|
16
|
+
"audioTrack": "Audio",
|
|
17
|
+
"caption": "Caption",
|
|
18
|
+
"display": "Display"
|
|
18
19
|
};
|
|
19
20
|
const SettingButton = function ($container, api) {
|
|
20
21
|
let panelManager = PanelManager();
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
function generateMainData(api) {
|
|
23
24
|
let panel = {
|
|
24
|
-
id
|
|
25
|
-
title
|
|
26
|
-
body
|
|
27
|
-
isRoot
|
|
28
|
-
panelType
|
|
25
|
+
id: "panel-" + new Date().getTime(),
|
|
26
|
+
title: "Settings",
|
|
27
|
+
body: [],
|
|
28
|
+
isRoot: true,
|
|
29
|
+
panelType: ""
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
let playerConfig = api.getConfig();
|
|
32
33
|
|
|
33
|
-
if(playerConfig && playerConfig.systemText){
|
|
34
|
+
if (playerConfig && playerConfig.systemText) {
|
|
34
35
|
Object.keys(PANEL_TITLE).forEach(title => {
|
|
35
36
|
PANEL_TITLE[title] = playerConfig.systemText.ui.setting[title];
|
|
36
37
|
});
|
|
@@ -42,29 +43,32 @@ const SettingButton = function ($container, api) {
|
|
|
42
43
|
let qualityLevels = api.getQualityLevels();
|
|
43
44
|
let currentQuality = qualityLevels && qualityLevels.length > 0 ? qualityLevels[api.getCurrentQuality()] : null;
|
|
44
45
|
|
|
46
|
+
let audioTracks = api.getAudioTracks();
|
|
47
|
+
let currentAudioTrack = audioTracks && audioTracks.length > 0 ? audioTracks[api.getCurrentAudioTrack()] : null;
|
|
48
|
+
|
|
45
49
|
let captions = api.getCaptionList();
|
|
46
50
|
let currentCaption = api.getCurrentCaption();
|
|
47
51
|
|
|
48
52
|
let framerate = api.getFramerate();
|
|
49
53
|
|
|
50
|
-
if(
|
|
54
|
+
if (currentSource) {
|
|
51
55
|
let body = {
|
|
52
|
-
title
|
|
53
|
-
value
|
|
54
|
-
description
|
|
55
|
-
panelType
|
|
56
|
-
hasNext
|
|
56
|
+
title: PANEL_TITLE.speed,
|
|
57
|
+
value: api.getPlaybackRate() + PANEL_TITLE.speedUnit,
|
|
58
|
+
description: api.getPlaybackRate() + PANEL_TITLE.speedUnit,
|
|
59
|
+
panelType: "speed",
|
|
60
|
+
hasNext: true
|
|
57
61
|
};
|
|
58
62
|
panel.body.push(body);
|
|
59
63
|
}
|
|
60
|
-
if (sources && sources.length >
|
|
64
|
+
if (sources && sources.length > 1) {
|
|
61
65
|
|
|
62
66
|
let body = {
|
|
63
|
-
title
|
|
64
|
-
value
|
|
65
|
-
description
|
|
66
|
-
panelType
|
|
67
|
-
hasNext
|
|
67
|
+
title: PANEL_TITLE.source,
|
|
68
|
+
value: currentSource ? currentSource.label : "Default",
|
|
69
|
+
description: currentSource ? currentSource.label : "Default",
|
|
70
|
+
panelType: "source",
|
|
71
|
+
hasNext: true
|
|
68
72
|
};
|
|
69
73
|
|
|
70
74
|
panel.body.push(body);
|
|
@@ -72,34 +76,48 @@ const SettingButton = function ($container, api) {
|
|
|
72
76
|
if (qualityLevels && qualityLevels.length > 0) {
|
|
73
77
|
|
|
74
78
|
let body = {
|
|
75
|
-
title
|
|
76
|
-
value
|
|
77
|
-
description
|
|
78
|
-
panelType
|
|
79
|
-
hasNext
|
|
79
|
+
title: PANEL_TITLE.quality,
|
|
80
|
+
value: currentQuality ? currentQuality.label : "Default",
|
|
81
|
+
description: currentQuality ? currentQuality.label : "Default",
|
|
82
|
+
panelType: "quality",
|
|
83
|
+
hasNext: true
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
panel.body.push(body);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (audioTracks && audioTracks.length > 0) {
|
|
90
|
+
|
|
91
|
+
let body = {
|
|
92
|
+
title: PANEL_TITLE.audioTrack,
|
|
93
|
+
value: currentAudioTrack ? currentAudioTrack.label : "Default",
|
|
94
|
+
description: currentAudioTrack ? currentAudioTrack.label : "Default",
|
|
95
|
+
panelType: "audioTrack",
|
|
96
|
+
hasNext: true
|
|
80
97
|
};
|
|
81
98
|
|
|
82
99
|
panel.body.push(body);
|
|
83
100
|
}
|
|
101
|
+
|
|
84
102
|
if (captions && captions.length > 0) {
|
|
85
103
|
|
|
86
104
|
let body = {
|
|
87
|
-
title
|
|
88
|
-
value
|
|
89
|
-
description
|
|
90
|
-
panelType
|
|
91
|
-
hasNext
|
|
105
|
+
title: PANEL_TITLE.caption,
|
|
106
|
+
value: captions[currentCaption] ? captions[currentCaption].label : "OFF",
|
|
107
|
+
description: captions[currentCaption] ? captions[currentCaption].label : "OFF",
|
|
108
|
+
panelType: "caption",
|
|
109
|
+
hasNext: true
|
|
92
110
|
};
|
|
93
111
|
|
|
94
112
|
panel.body.push(body);
|
|
95
113
|
}
|
|
96
|
-
if(framerate > 0){
|
|
114
|
+
if (framerate > 0) {
|
|
97
115
|
let body = {
|
|
98
|
-
title
|
|
99
|
-
value
|
|
100
|
-
description
|
|
101
|
-
panelType
|
|
102
|
-
hasNext
|
|
116
|
+
title: PANEL_TITLE.display,
|
|
117
|
+
value: api.isTimecodeMode() ? "Play time" : "Framecode",
|
|
118
|
+
description: api.isTimecodeMode() ? "Play time" : "Framecode",
|
|
119
|
+
panelType: "display",
|
|
120
|
+
hasNext: true
|
|
103
121
|
};
|
|
104
122
|
|
|
105
123
|
panel.body.push(body);
|
|
@@ -108,26 +126,25 @@ const SettingButton = function ($container, api) {
|
|
|
108
126
|
return panel;
|
|
109
127
|
};
|
|
110
128
|
|
|
111
|
-
const onRendered = function($current, template){
|
|
129
|
+
const onRendered = function ($current, template) {
|
|
112
130
|
};
|
|
113
|
-
const onDestroyed = function(template){
|
|
131
|
+
const onDestroyed = function (template) {
|
|
114
132
|
};
|
|
115
133
|
const events = {
|
|
116
|
-
"click .op-setting-button"
|
|
134
|
+
"click .op-setting-button": function (event, $current, template) {
|
|
117
135
|
event.preventDefault();
|
|
118
136
|
let $parent = $current.closest(".op-controls-container");
|
|
119
|
-
if(panelManager.size() > 0){
|
|
137
|
+
if (panelManager.size() > 0) {
|
|
120
138
|
panelManager.clear();
|
|
121
|
-
}else{
|
|
139
|
+
} else {
|
|
122
140
|
let panelData = generateMainData(api);
|
|
123
141
|
panelManager.add(Panels($parent, api, panelData));
|
|
124
142
|
}
|
|
125
143
|
},
|
|
126
144
|
};
|
|
127
145
|
|
|
128
|
-
return OvenTemplate($container, "SettingButton", api.getConfig(), null, events, onRendered, onDestroyed
|
|
146
|
+
return OvenTemplate($container, "SettingButton", api.getConfig(), null, events, onRendered, onDestroyed);
|
|
129
147
|
};
|
|
130
148
|
|
|
131
149
|
|
|
132
|
-
|
|
133
150
|
export default SettingButton;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by hoho on 2018. 7. 26..
|
|
3
|
+
*/
|
|
4
|
+
import OvenTemplate from 'view/engine/OvenTemplate';
|
|
5
|
+
import PanelManager from "view/global/PanelManager";
|
|
6
|
+
import LA$ from 'utils/likeA$';
|
|
7
|
+
import {
|
|
8
|
+
AUDIO_TRACK_CHANGED
|
|
9
|
+
} from "api/constants";
|
|
10
|
+
import _ from "utils/underscore";
|
|
11
|
+
|
|
12
|
+
const AudioTrackPanel = function ($container, api, data) {
|
|
13
|
+
const $root = LA$(api.getContainerElement());
|
|
14
|
+
let panelManager = PanelManager();
|
|
15
|
+
|
|
16
|
+
data.setFront = function (isFront) {
|
|
17
|
+
if (isFront) {
|
|
18
|
+
$root.find("#" + data.id).removeClass("background");
|
|
19
|
+
} else {
|
|
20
|
+
$root.find("#" + data.id).addClass("background");
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const onRendered = function ($current, template) {
|
|
24
|
+
api.on(AUDIO_TRACK_CHANGED, function (data) {
|
|
25
|
+
_.forEach($root.find("#" + template.data.id).find(".op-setting-item").get(), function (panel) {
|
|
26
|
+
let $panel = LA$(panel);
|
|
27
|
+
|
|
28
|
+
if ($panel.find(".op-setting-item-checked").hasClass("op-show")) {
|
|
29
|
+
$panel.find(".op-setting-item-checked").removeClass("op-show");
|
|
30
|
+
}
|
|
31
|
+
if (data.currentAudioTrack === parseInt($panel.attr("op-data-value"))) {
|
|
32
|
+
$panel.find(".op-setting-item-checked").addClass("op-show");
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}, template);
|
|
36
|
+
};
|
|
37
|
+
const onDestroyed = function (template) {
|
|
38
|
+
api.off(AUDIO_TRACK_CHANGED, null, template);
|
|
39
|
+
};
|
|
40
|
+
const events = {
|
|
41
|
+
"click .op-setting-item": function (event, $current, template) {
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
let value = LA$(event.currentTarget).attr("op-data-value");
|
|
44
|
+
api.setCurrentAudioTrack(parseInt(value));
|
|
45
|
+
panelManager.clear();
|
|
46
|
+
},
|
|
47
|
+
"click .op-setting-title": function (event, $current, template) {
|
|
48
|
+
event.preventDefault();
|
|
49
|
+
panelManager.removeLastItem();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return OvenTemplate($container, "AudioTrackPanel", api.getConfig(), data, events, onRendered, onDestroyed);
|
|
54
|
+
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default AudioTrackPanel;
|