@checksub_team/peaks_timeline 1.16.1 → 2.0.0-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/package.json +1 -1
- package/peaks.js +4716 -4409
- package/peaks.js.d.ts +5 -5
- package/src/{timeline-axis.js → components/axis.js} +244 -244
- package/src/{data-retriever.js → components/data-retriever.js} +117 -117
- package/src/{default-segment-marker.js → components/default-segment-marker.js} +132 -132
- package/src/{invoker.js → components/invoker.js} +81 -81
- package/src/components/line-group.js +692 -0
- package/src/components/line-groups.js +585 -0
- package/src/{line-indicator.js → components/line-indicator.js} +308 -303
- package/src/{marker-factories.js → components/marker-factories.js} +1 -1
- package/src/{mode-layer.js → components/mode-layer.js} +8 -12
- package/src/{playhead-layer.js → components/playhead-layer.js} +3 -3
- package/src/{segment-marker.js → components/segment-marker.js} +2 -2
- package/src/{segment-shape.js → components/segment-shape.js} +508 -508
- package/src/{segments-group.js → components/segments-group.js} +805 -801
- package/src/{source-group.js → components/source-group.js} +1661 -1640
- package/src/{sources-layer.js → components/sources-layer.js} +716 -730
- package/src/{waveform-builder.js → components/waveform-builder.js} +2 -2
- package/src/{waveform-shape.js → components/waveform-shape.js} +214 -214
- package/src/keyboard-handler.js +9 -9
- package/src/line-handler.js +179 -0
- package/src/main.js +110 -71
- package/src/models/line.js +156 -0
- package/src/{segment.js → models/segment.js} +420 -419
- package/src/{source.js → models/source.js} +1311 -1315
- package/src/player.js +2 -2
- package/src/{timeline-segments.js → segment-handler.js} +435 -435
- package/src/{timeline-sources.js → source-handler.js} +521 -514
- package/src/utils.js +5 -1
- package/src/{timeline-zoomview.js → view.js} +136 -137
- package/src/line.js +0 -690
- package/src/lines.js +0 -427
- /package/src/{data.js → components/data.js} +0 -0
- /package/src/{loader.js → components/loader.js} +0 -0
- /package/src/{mouse-drag-handler.js → components/mouse-drag-handler.js} +0 -0
- /package/src/{svgs.js → components/svgs.js} +0 -0
|
@@ -1,1315 +1,1311 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file
|
|
3
|
-
*
|
|
4
|
-
* Defines the {@link source} class.
|
|
5
|
-
*
|
|
6
|
-
* @module source
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
define([
|
|
10
|
-
'
|
|
11
|
-
], function(Utils) {
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
|
-
function validateSource(peaks, options, context) {
|
|
15
|
-
if (!Utils.isValidTime(options.startTime)) {
|
|
16
|
-
throw new TypeError('peaks.sources.' + context + ': startTime should be a valid number');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (!Utils.isValidTime(options.endTime)) {
|
|
20
|
-
throw new TypeError('peaks.sources.' + context + ': endTime should be a valid number');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (!Utils.isValidTime(options.duration) || options.duration <= 0) {
|
|
24
|
-
options.duration = 0;
|
|
25
|
-
}
|
|
26
|
-
else if (options.duration < peaks.options.minSourceSize) {
|
|
27
|
-
options.duration = peaks.options.minSourceSize;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
options.duration = Utils.roundTime(options.duration);
|
|
31
|
-
|
|
32
|
-
if (options.startTime < 0) {
|
|
33
|
-
throw new RangeError('peaks.sources.' + context + ': startTime should be positive');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (options.endTime < 0) {
|
|
37
|
-
throw new RangeError('peaks.sources.' + context + ': endTime should be positive');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (options.endTime <= options.startTime) {
|
|
41
|
-
throw new RangeError(
|
|
42
|
-
'peaks.sources.' + context + ': endTime should be greater than startTime'
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (options.endTime - options.startTime < peaks.options.minSourceSize) {
|
|
47
|
-
options.endTime = options.startTime + peaks.options.minSourceSize;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (!Utils.isValidTime(options.mediaStartTime) || options.mediaStartTime < 0) {
|
|
51
|
-
options.mediaStartTime = 0;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (!Utils.isValidTime(options.mediaEndTime)
|
|
55
|
-
|| (options.mediaEndTime < options.mediaStartTime)
|
|
56
|
-
|| (options.mediaEndTime - options.mediaStartTime !== options.endTime - options.startTime)) {
|
|
57
|
-
options.mediaEndTime = options.mediaStartTime + (options.endTime - options.startTime);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (options.duration && options.mediaEndTime > options.duration) {
|
|
61
|
-
var timeWidth = options.mediaEndTime - options.mediaStartTime;
|
|
62
|
-
|
|
63
|
-
options.mediaEndTime = options.duration;
|
|
64
|
-
if (options.duration > timeWidth) {
|
|
65
|
-
options.mediaStartTime = options.mediaEndTime - timeWidth;
|
|
66
|
-
options.endTime = options.startTime + timeWidth;
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
options.mediaStartTime = 0;
|
|
70
|
-
options.endTime = options.startTime + options.duration;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
options.startTime = Utils.roundTime(options.startTime);
|
|
75
|
-
options.endTime = Utils.roundTime(options.endTime);
|
|
76
|
-
options.mediaStartTime = Utils.roundTime(options.mediaStartTime);
|
|
77
|
-
options.mediaEndTime = Utils.roundTime(options.mediaEndTime);
|
|
78
|
-
|
|
79
|
-
if (Utils.isNullOrUndefined(options.title)) {
|
|
80
|
-
options.title = '';
|
|
81
|
-
}
|
|
82
|
-
else if (!Utils.isString(options.title)) {
|
|
83
|
-
throw new TypeError('peaks.sources.' + context + ': title must be a string');
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (Utils.isNullOrUndefined(options.titleAlignments)) {
|
|
87
|
-
options.titleAlignments = [];
|
|
88
|
-
}
|
|
89
|
-
else if (!Array.isArray(options.titleAlignments)) {
|
|
90
|
-
throw new TypeError('peaks.sources.' + context + ': titleAlignments must be an array');
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (Utils.isNullOrUndefined(options.url)) {
|
|
94
|
-
options.url = '';
|
|
95
|
-
}
|
|
96
|
-
else if (!Utils.isString(options.url)) {
|
|
97
|
-
throw new TypeError('peaks.sources.' + context + ': url must be a string');
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (Utils.isNullOrUndefined(options.previewUrl)) {
|
|
101
|
-
options.previewUrl = '';
|
|
102
|
-
}
|
|
103
|
-
else if (!Utils.isString(options.previewUrl)) {
|
|
104
|
-
throw new TypeError('peaks.sources.' + context + ': previewUrl must be a string');
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (Utils.isNullOrUndefined(options.binaryUrl)) {
|
|
108
|
-
options.binaryUrl = '';
|
|
109
|
-
}
|
|
110
|
-
else if (!Utils.isString(options.binaryUrl)) {
|
|
111
|
-
throw new TypeError('peaks.sources.' + context + ': binaryUrl must be a string');
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (!Utils.isValidColor(options.color)) {
|
|
115
|
-
options.color = peaks.options.zoomWaveformColor;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (!Utils.isValidColor(options.backgroundColor)) {
|
|
119
|
-
throw new TypeError(
|
|
120
|
-
'peaks.sources.' + context + ': backgroundColor should be a valid CSS color'
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (Utils.isNullOrUndefined(options.selectedBackgroundColor)) {
|
|
125
|
-
options.selectedBackgroundColor = options.backgroundColor;
|
|
126
|
-
}
|
|
127
|
-
else if (!Utils.isValidColor(options.selectedBackgroundColor)) {
|
|
128
|
-
throw new TypeError(
|
|
129
|
-
'peaks.sources.' + context + ': selectedBackgroundColor should be a valid CSS color'
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (Utils.isNullOrUndefined(options.hoverBackgroundColor)) {
|
|
134
|
-
options.hoverBackgroundColor = Utils.shadeColor(options.backgroundColor, 30);
|
|
135
|
-
}
|
|
136
|
-
else if (!Utils.isValidColor(options.hoverBackgroundColor)) {
|
|
137
|
-
throw new TypeError(
|
|
138
|
-
'peaks.sources.' + context + ': hoverBackgroundColor should be a valid CSS color'
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (
|
|
143
|
-
options.borderColor = options.color;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
throw new TypeError(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
options.markerColor
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
||
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
* @
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
* @param {
|
|
380
|
-
* @param {String}
|
|
381
|
-
* @param {String}
|
|
382
|
-
* @param {String}
|
|
383
|
-
* @param {
|
|
384
|
-
*
|
|
385
|
-
* @param {
|
|
386
|
-
*
|
|
387
|
-
* @param {String}
|
|
388
|
-
* @param {String}
|
|
389
|
-
* @param {String}
|
|
390
|
-
* @param {
|
|
391
|
-
* @param {
|
|
392
|
-
* @param {Number}
|
|
393
|
-
* @param {Number}
|
|
394
|
-
* @param {Number}
|
|
395
|
-
* @param {
|
|
396
|
-
* @param {
|
|
397
|
-
* @param {String}
|
|
398
|
-
* @param {String}
|
|
399
|
-
* @param {String}
|
|
400
|
-
* @param {String}
|
|
401
|
-
* @param {
|
|
402
|
-
* @param {
|
|
403
|
-
* @param {
|
|
404
|
-
* @param {Number}
|
|
405
|
-
* @param {String}
|
|
406
|
-
* @param {
|
|
407
|
-
* @param {String}
|
|
408
|
-
* @param {
|
|
409
|
-
* @param {
|
|
410
|
-
* @param {
|
|
411
|
-
* @param {
|
|
412
|
-
* @param {Number}
|
|
413
|
-
* @param {Boolean}
|
|
414
|
-
* @param {Boolean}
|
|
415
|
-
* @param {Boolean}
|
|
416
|
-
* @param {Boolean}
|
|
417
|
-
* @param {Boolean}
|
|
418
|
-
* @param {
|
|
419
|
-
* @param {
|
|
420
|
-
* @param {Number}
|
|
421
|
-
* @param {
|
|
422
|
-
* @param {Array}
|
|
423
|
-
* @param {Array}
|
|
424
|
-
* @param {
|
|
425
|
-
* @param {
|
|
426
|
-
* @param {Number}
|
|
427
|
-
* @param {
|
|
428
|
-
* @param {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
draggable: draggable,
|
|
473
|
-
orderable: orderable,
|
|
474
|
-
resizable: resizable,
|
|
475
|
-
cuttable: cuttable,
|
|
476
|
-
deletable: deletable,
|
|
477
|
-
wrapping: wrapping,
|
|
478
|
-
previewHeight: previewHeight,
|
|
479
|
-
binaryHeight: binaryHeight,
|
|
480
|
-
indicators: indicators,
|
|
481
|
-
markers: markers,
|
|
482
|
-
buttons: buttons,
|
|
483
|
-
markerColor: markerColor,
|
|
484
|
-
markerWidth: markerWidth,
|
|
485
|
-
volume: volume,
|
|
486
|
-
volumeRange: volumeRange,
|
|
487
|
-
loading: loading
|
|
488
|
-
};
|
|
489
|
-
|
|
490
|
-
validateSource(peaks, opts, 'add()');
|
|
491
|
-
|
|
492
|
-
this._peaks = peaks;
|
|
493
|
-
this._id = id;
|
|
494
|
-
this.
|
|
495
|
-
this.
|
|
496
|
-
this.
|
|
497
|
-
this.
|
|
498
|
-
this.
|
|
499
|
-
this.
|
|
500
|
-
this.
|
|
501
|
-
this.
|
|
502
|
-
this.
|
|
503
|
-
this.
|
|
504
|
-
this.
|
|
505
|
-
this.
|
|
506
|
-
this.
|
|
507
|
-
this.
|
|
508
|
-
this.
|
|
509
|
-
this.
|
|
510
|
-
this.
|
|
511
|
-
this.
|
|
512
|
-
this.
|
|
513
|
-
this.
|
|
514
|
-
this.
|
|
515
|
-
this.
|
|
516
|
-
this.
|
|
517
|
-
this.
|
|
518
|
-
this.
|
|
519
|
-
this.
|
|
520
|
-
this.
|
|
521
|
-
this.
|
|
522
|
-
this.
|
|
523
|
-
this.
|
|
524
|
-
this.
|
|
525
|
-
this.
|
|
526
|
-
this.
|
|
527
|
-
this.
|
|
528
|
-
this.
|
|
529
|
-
this._draggable = opts.draggable;
|
|
530
|
-
this._orderable = opts.orderable;
|
|
531
|
-
this._resizable = opts.resizable;
|
|
532
|
-
this._cuttable = opts.cuttable;
|
|
533
|
-
this._deletable = opts.deletable;
|
|
534
|
-
this._wrapping = opts.wrapping;
|
|
535
|
-
this._previewHeight = opts.previewHeight;
|
|
536
|
-
this._binaryHeight = opts.binaryHeight;
|
|
537
|
-
this._indicators = opts.indicators;
|
|
538
|
-
this._markers = opts.markers;
|
|
539
|
-
this._buttons = opts.buttons;
|
|
540
|
-
this._markerColor = opts.markerColor;
|
|
541
|
-
this._markerWidth = opts.markerWidth;
|
|
542
|
-
this._volume = opts.volume;
|
|
543
|
-
this._volumeRange = opts.volumeRange;
|
|
544
|
-
this._loading = opts.loading;
|
|
545
|
-
this._minSize = peaks.options.minSourceSize;
|
|
546
|
-
this._selected = false;
|
|
547
|
-
|
|
548
|
-
for (var i = 0; i < customParams.length; i += 2) {
|
|
549
|
-
var key = customParams[i];
|
|
550
|
-
var value = customParams[i + 1];
|
|
551
|
-
|
|
552
|
-
if (key && key.startsWith('custom_')) {
|
|
553
|
-
this[key] = value;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
Object.defineProperties(Source.prototype, {
|
|
559
|
-
id: {
|
|
560
|
-
enumerable: true,
|
|
561
|
-
get: function() {
|
|
562
|
-
return this._id;
|
|
563
|
-
}
|
|
564
|
-
},
|
|
565
|
-
|
|
566
|
-
enumerable: true,
|
|
567
|
-
get: function() {
|
|
568
|
-
return this.
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
this.
|
|
585
|
-
}
|
|
586
|
-
},
|
|
587
|
-
|
|
588
|
-
enumerable: true,
|
|
589
|
-
get: function() {
|
|
590
|
-
return this.
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
this.
|
|
619
|
-
}
|
|
620
|
-
},
|
|
621
|
-
|
|
622
|
-
enumerable: true,
|
|
623
|
-
get: function() {
|
|
624
|
-
return this.
|
|
625
|
-
},
|
|
626
|
-
|
|
627
|
-
set: function(
|
|
628
|
-
this.
|
|
629
|
-
}
|
|
630
|
-
},
|
|
631
|
-
|
|
632
|
-
enumerable: true,
|
|
633
|
-
get: function() {
|
|
634
|
-
return this.
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
this.
|
|
657
|
-
}
|
|
658
|
-
},
|
|
659
|
-
|
|
660
|
-
enumerable: true,
|
|
661
|
-
get: function() {
|
|
662
|
-
return this.
|
|
663
|
-
},
|
|
664
|
-
|
|
665
|
-
set: function(
|
|
666
|
-
this.
|
|
667
|
-
}
|
|
668
|
-
},
|
|
669
|
-
|
|
670
|
-
enumerable: true,
|
|
671
|
-
get: function() {
|
|
672
|
-
return this.
|
|
673
|
-
},
|
|
674
|
-
|
|
675
|
-
set: function(
|
|
676
|
-
this.
|
|
677
|
-
}
|
|
678
|
-
},
|
|
679
|
-
|
|
680
|
-
enumerable: true,
|
|
681
|
-
get: function() {
|
|
682
|
-
return this.
|
|
683
|
-
},
|
|
684
|
-
|
|
685
|
-
set: function(
|
|
686
|
-
this.
|
|
687
|
-
}
|
|
688
|
-
},
|
|
689
|
-
|
|
690
|
-
enumerable: true,
|
|
691
|
-
get: function() {
|
|
692
|
-
return this.
|
|
693
|
-
},
|
|
694
|
-
|
|
695
|
-
set: function(
|
|
696
|
-
this.
|
|
697
|
-
}
|
|
698
|
-
},
|
|
699
|
-
|
|
700
|
-
enumerable: true,
|
|
701
|
-
get: function() {
|
|
702
|
-
return this.
|
|
703
|
-
},
|
|
704
|
-
|
|
705
|
-
set: function(
|
|
706
|
-
this.
|
|
707
|
-
}
|
|
708
|
-
},
|
|
709
|
-
|
|
710
|
-
enumerable: true,
|
|
711
|
-
get: function() {
|
|
712
|
-
return this.
|
|
713
|
-
},
|
|
714
|
-
|
|
715
|
-
set: function(
|
|
716
|
-
this.
|
|
717
|
-
}
|
|
718
|
-
},
|
|
719
|
-
|
|
720
|
-
enumerable: true,
|
|
721
|
-
get: function() {
|
|
722
|
-
return this.
|
|
723
|
-
},
|
|
724
|
-
|
|
725
|
-
set: function(
|
|
726
|
-
this.
|
|
727
|
-
}
|
|
728
|
-
},
|
|
729
|
-
|
|
730
|
-
enumerable: true,
|
|
731
|
-
get: function() {
|
|
732
|
-
return this.
|
|
733
|
-
},
|
|
734
|
-
|
|
735
|
-
set: function(
|
|
736
|
-
this.
|
|
737
|
-
}
|
|
738
|
-
},
|
|
739
|
-
|
|
740
|
-
enumerable: true,
|
|
741
|
-
get: function() {
|
|
742
|
-
return this.
|
|
743
|
-
},
|
|
744
|
-
|
|
745
|
-
set: function(
|
|
746
|
-
this.
|
|
747
|
-
}
|
|
748
|
-
},
|
|
749
|
-
|
|
750
|
-
enumerable: true,
|
|
751
|
-
get: function() {
|
|
752
|
-
return this.
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
this.
|
|
775
|
-
}
|
|
776
|
-
},
|
|
777
|
-
|
|
778
|
-
enumerable: true,
|
|
779
|
-
get: function() {
|
|
780
|
-
return this.
|
|
781
|
-
},
|
|
782
|
-
|
|
783
|
-
set: function(
|
|
784
|
-
this.
|
|
785
|
-
}
|
|
786
|
-
},
|
|
787
|
-
|
|
788
|
-
enumerable: true,
|
|
789
|
-
get: function() {
|
|
790
|
-
return this.
|
|
791
|
-
},
|
|
792
|
-
|
|
793
|
-
set: function(
|
|
794
|
-
this.
|
|
795
|
-
}
|
|
796
|
-
},
|
|
797
|
-
|
|
798
|
-
enumerable: true,
|
|
799
|
-
get: function() {
|
|
800
|
-
return this.
|
|
801
|
-
},
|
|
802
|
-
|
|
803
|
-
set: function(
|
|
804
|
-
this.
|
|
805
|
-
}
|
|
806
|
-
},
|
|
807
|
-
|
|
808
|
-
enumerable: true,
|
|
809
|
-
get: function() {
|
|
810
|
-
return this.
|
|
811
|
-
},
|
|
812
|
-
|
|
813
|
-
set: function(
|
|
814
|
-
this.
|
|
815
|
-
}
|
|
816
|
-
},
|
|
817
|
-
|
|
818
|
-
enumerable: true,
|
|
819
|
-
get: function() {
|
|
820
|
-
return this.
|
|
821
|
-
},
|
|
822
|
-
|
|
823
|
-
set: function(
|
|
824
|
-
this.
|
|
825
|
-
}
|
|
826
|
-
},
|
|
827
|
-
|
|
828
|
-
enumerable: true,
|
|
829
|
-
get: function() {
|
|
830
|
-
return this.
|
|
831
|
-
},
|
|
832
|
-
|
|
833
|
-
set: function(
|
|
834
|
-
this.
|
|
835
|
-
}
|
|
836
|
-
},
|
|
837
|
-
|
|
838
|
-
enumerable: true,
|
|
839
|
-
get: function() {
|
|
840
|
-
return this.
|
|
841
|
-
},
|
|
842
|
-
|
|
843
|
-
set: function(
|
|
844
|
-
this.
|
|
845
|
-
}
|
|
846
|
-
},
|
|
847
|
-
|
|
848
|
-
enumerable: true,
|
|
849
|
-
get: function() {
|
|
850
|
-
return this.
|
|
851
|
-
},
|
|
852
|
-
|
|
853
|
-
set: function(
|
|
854
|
-
this.
|
|
855
|
-
}
|
|
856
|
-
},
|
|
857
|
-
|
|
858
|
-
enumerable: true,
|
|
859
|
-
get: function() {
|
|
860
|
-
return this.
|
|
861
|
-
},
|
|
862
|
-
|
|
863
|
-
set: function(
|
|
864
|
-
this.
|
|
865
|
-
}
|
|
866
|
-
},
|
|
867
|
-
segments: {
|
|
868
|
-
enumerable: true,
|
|
869
|
-
get: function() {
|
|
870
|
-
return this._segments;
|
|
871
|
-
}
|
|
872
|
-
},
|
|
873
|
-
draggable: {
|
|
874
|
-
enumerable: true,
|
|
875
|
-
get: function() {
|
|
876
|
-
return this._draggable;
|
|
877
|
-
}
|
|
878
|
-
},
|
|
879
|
-
orderable: {
|
|
880
|
-
enumerable: true,
|
|
881
|
-
get: function() {
|
|
882
|
-
return this._orderable;
|
|
883
|
-
}
|
|
884
|
-
},
|
|
885
|
-
resizable: {
|
|
886
|
-
enumerable: true,
|
|
887
|
-
get: function() {
|
|
888
|
-
return this._resizable;
|
|
889
|
-
}
|
|
890
|
-
},
|
|
891
|
-
cuttable: {
|
|
892
|
-
enumerable: true,
|
|
893
|
-
get: function() {
|
|
894
|
-
return this._cuttable;
|
|
895
|
-
}
|
|
896
|
-
},
|
|
897
|
-
deletable: {
|
|
898
|
-
enumerable: true,
|
|
899
|
-
get: function() {
|
|
900
|
-
return this._deletable;
|
|
901
|
-
}
|
|
902
|
-
},
|
|
903
|
-
wrapping: {
|
|
904
|
-
enumerable: true,
|
|
905
|
-
get: function() {
|
|
906
|
-
return this._wrapping;
|
|
907
|
-
},
|
|
908
|
-
|
|
909
|
-
set: function(wrapping) {
|
|
910
|
-
this._wrapping = wrapping;
|
|
911
|
-
}
|
|
912
|
-
},
|
|
913
|
-
previewHeight: {
|
|
914
|
-
enumerable: true,
|
|
915
|
-
get: function() {
|
|
916
|
-
return this._previewHeight;
|
|
917
|
-
},
|
|
918
|
-
|
|
919
|
-
set: function(previewHeight) {
|
|
920
|
-
this._previewHeight = previewHeight;
|
|
921
|
-
}
|
|
922
|
-
},
|
|
923
|
-
binaryHeight: {
|
|
924
|
-
enumerable: true,
|
|
925
|
-
get: function() {
|
|
926
|
-
return this._binaryHeight;
|
|
927
|
-
},
|
|
928
|
-
|
|
929
|
-
set: function(binaryHeight) {
|
|
930
|
-
this._binaryHeight = binaryHeight;
|
|
931
|
-
}
|
|
932
|
-
},
|
|
933
|
-
indicators: {
|
|
934
|
-
enumerable: true,
|
|
935
|
-
get: function() {
|
|
936
|
-
return this._indicators;
|
|
937
|
-
}
|
|
938
|
-
},
|
|
939
|
-
markers: {
|
|
940
|
-
enumerable: true,
|
|
941
|
-
get: function() {
|
|
942
|
-
return this._markers;
|
|
943
|
-
}
|
|
944
|
-
},
|
|
945
|
-
buttons: {
|
|
946
|
-
enumerable: true,
|
|
947
|
-
get: function() {
|
|
948
|
-
return this._buttons;
|
|
949
|
-
}
|
|
950
|
-
},
|
|
951
|
-
markerColor: {
|
|
952
|
-
enumerable: true,
|
|
953
|
-
get: function() {
|
|
954
|
-
return this._markerColor;
|
|
955
|
-
}
|
|
956
|
-
},
|
|
957
|
-
markerWidth: {
|
|
958
|
-
enumerable: true,
|
|
959
|
-
get: function() {
|
|
960
|
-
return this._markerWidth;
|
|
961
|
-
}
|
|
962
|
-
},
|
|
963
|
-
volume: {
|
|
964
|
-
enumerable: true,
|
|
965
|
-
get: function() {
|
|
966
|
-
return this._volume;
|
|
967
|
-
},
|
|
968
|
-
|
|
969
|
-
set: function(volume) {
|
|
970
|
-
this._volume = volume;
|
|
971
|
-
}
|
|
972
|
-
},
|
|
973
|
-
volumeRange: {
|
|
974
|
-
enumerable: true,
|
|
975
|
-
get: function() {
|
|
976
|
-
return this._volumeRange;
|
|
977
|
-
}
|
|
978
|
-
},
|
|
979
|
-
loading: {
|
|
980
|
-
enumerable: true,
|
|
981
|
-
get: function() {
|
|
982
|
-
return this._loading;
|
|
983
|
-
}
|
|
984
|
-
},
|
|
985
|
-
minSize: {
|
|
986
|
-
enumerable: true,
|
|
987
|
-
get: function() {
|
|
988
|
-
return this._minSize;
|
|
989
|
-
}
|
|
990
|
-
},
|
|
991
|
-
selected: {
|
|
992
|
-
enumerable: true,
|
|
993
|
-
get: function() {
|
|
994
|
-
return this._selected;
|
|
995
|
-
},
|
|
996
|
-
|
|
997
|
-
set: function(selected) {
|
|
998
|
-
this._selected = selected;
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
});
|
|
1002
|
-
|
|
1003
|
-
Source.prototype.updateTimes = function(newStartTime, newEndTime) {
|
|
1004
|
-
if (newStartTime
|
|
1005
|
-
if (this._duration && newEndTime
|
|
1006
|
-
newStartTime = Utils.roundTime(Math.max(this._endTime - this._duration, newStartTime));
|
|
1007
|
-
}
|
|
1008
|
-
else {
|
|
1009
|
-
newStartTime = Utils.roundTime(newStartTime);
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
if (newEndTime
|
|
1014
|
-
if (this._duration && newStartTime
|
|
1015
|
-
newEndTime = Utils.roundTime(Math.min(this._startTime + this._duration, newEndTime));
|
|
1016
|
-
}
|
|
1017
|
-
else {
|
|
1018
|
-
newEndTime = Utils.roundTime(newEndTime);
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
if ((newStartTime
|
|
1023
|
-
|| (newStartTime
|
|
1024
|
-
this._updateMediaRange(this._startTime, newStartTime, this._endTime, newEndTime);
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
if (newStartTime
|
|
1028
|
-
this._startTime = newStartTime;
|
|
1029
|
-
}
|
|
1030
|
-
if (newEndTime
|
|
1031
|
-
this._endTime = newEndTime;
|
|
1032
|
-
}
|
|
1033
|
-
};
|
|
1034
|
-
|
|
1035
|
-
Source.prototype._updateMediaRange = function(oldStartTime, newStartTime, oldEndTime,
|
|
1036
|
-
newEndTime) {
|
|
1037
|
-
var startDiff = 0;
|
|
1038
|
-
var endDiff = 0;
|
|
1039
|
-
var upperLimit;
|
|
1040
|
-
|
|
1041
|
-
if (this._duration) {
|
|
1042
|
-
upperLimit = this._duration;
|
|
1043
|
-
}
|
|
1044
|
-
else {
|
|
1045
|
-
upperLimit = Number.POSITIVE_INFINITY;
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
if (newStartTime
|
|
1049
|
-
startDiff = newStartTime - oldStartTime;
|
|
1050
|
-
}
|
|
1051
|
-
if (newEndTime
|
|
1052
|
-
endDiff = newEndTime - oldEndTime;
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
var newMediaStartTime = this._mediaStartTime;
|
|
1056
|
-
var newMediaEndTime = this._mediaEndTime;
|
|
1057
|
-
|
|
1058
|
-
if (startDiff) {
|
|
1059
|
-
if (startDiff < 0) {
|
|
1060
|
-
// Try reducing mediaStartTime
|
|
1061
|
-
if (newMediaStartTime > 0) {
|
|
1062
|
-
var minStartTime = newMediaStartTime + startDiff;
|
|
1063
|
-
|
|
1064
|
-
newMediaStartTime = Math.max(0, minStartTime);
|
|
1065
|
-
if (minStartTime < 0) {
|
|
1066
|
-
// Try increasing mediaEndTime
|
|
1067
|
-
newMediaEndTime = Math.min(upperLimit, newMediaEndTime - minStartTime);
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
else {
|
|
1071
|
-
// Try increasing mediaEndTime
|
|
1072
|
-
newMediaEndTime = Math.min(upperLimit, newMediaEndTime - startDiff);
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
else {
|
|
1076
|
-
// Try increasing mediaStartTime
|
|
1077
|
-
if (newMediaStartTime < upperLimit) {
|
|
1078
|
-
newMediaStartTime = Math.min(upperLimit, newMediaStartTime + startDiff);
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
if (endDiff) {
|
|
1084
|
-
if (endDiff > 0) {
|
|
1085
|
-
// Try increasing mediaEndTime
|
|
1086
|
-
if (newMediaEndTime < upperLimit) {
|
|
1087
|
-
var maxEndTime = newMediaEndTime + endDiff;
|
|
1088
|
-
|
|
1089
|
-
newMediaEndTime = Math.min(upperLimit, maxEndTime);
|
|
1090
|
-
if (maxEndTime > upperLimit) {
|
|
1091
|
-
// Try reducing mediaStartTime
|
|
1092
|
-
newMediaStartTime = Math.max(0, newMediaStartTime - (maxEndTime - upperLimit));
|
|
1093
|
-
}
|
|
1094
|
-
}
|
|
1095
|
-
else {
|
|
1096
|
-
// Try reducing mediaStartTime
|
|
1097
|
-
newMediaStartTime = Math.max(0, newMediaStartTime - endDiff);
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
else {
|
|
1101
|
-
if (newEndTime - oldStartTime < upperLimit) {
|
|
1102
|
-
if (oldEndTime - oldStartTime > upperLimit) {
|
|
1103
|
-
endDiff += (oldEndTime - oldStartTime) - upperLimit;
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
// Try reducing mediaEndTime
|
|
1107
|
-
if (newMediaEndTime > 0) {
|
|
1108
|
-
newMediaEndTime = Math.max(0, newMediaEndTime + endDiff);
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
this._mediaStartTime = Utils.roundTime(newMediaStartTime);
|
|
1115
|
-
this._mediaEndTime = Utils.roundTime(newMediaEndTime);
|
|
1116
|
-
};
|
|
1117
|
-
|
|
1118
|
-
Source.prototype.update = function(options) {
|
|
1119
|
-
var opts = {
|
|
1120
|
-
title: this.title,
|
|
1121
|
-
titleAlignments: this.titleAlignments,
|
|
1122
|
-
url: this.url,
|
|
1123
|
-
previewUrl: this.previewUrl,
|
|
1124
|
-
binaryUrl: this.binaryUrl,
|
|
1125
|
-
kind: this.kind,
|
|
1126
|
-
subkind: this.subkind,
|
|
1127
|
-
duration: this.duration,
|
|
1128
|
-
startTime: this.startTime,
|
|
1129
|
-
endTime: this.endTime,
|
|
1130
|
-
mediaStartTime: this.mediaStartTime,
|
|
1131
|
-
mediaEndTime: this.mediaEndTime,
|
|
1132
|
-
color: this.color,
|
|
1133
|
-
backgroundColor: this.backgroundColor,
|
|
1134
|
-
hoverBackgroundColor: this.hoverBackgroundColor,
|
|
1135
|
-
selectedBackgroundColor: this.selectedBackgroundColor,
|
|
1136
|
-
borderColor: this.borderColor,
|
|
1137
|
-
selectedBorderColor: this.selectedBorderColor,
|
|
1138
|
-
warningColor: this.warningColor,
|
|
1139
|
-
warningWidth: this.warningWidth,
|
|
1140
|
-
volumeSliderColor: this.volumeSliderColor,
|
|
1141
|
-
volumeSliderWidth: this.volumeSliderWidth,
|
|
1142
|
-
volumeSliderDraggingWidth: this.volumeSliderDraggingWidth,
|
|
1143
|
-
textFont: this.textFont,
|
|
1144
|
-
textFontSize: this.textFontSize,
|
|
1145
|
-
textColor: this.textColor,
|
|
1146
|
-
textBackgroundColor: this.textBackgroundColor,
|
|
1147
|
-
textPosition: this.textPosition,
|
|
1148
|
-
textAutoScroll: this.textAutoScroll,
|
|
1149
|
-
borderWidth: this.borderWidth,
|
|
1150
|
-
borderRadius: this.borderRadius,
|
|
1151
|
-
wrapped: this.wrapped,
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
this.
|
|
1176
|
-
this.
|
|
1177
|
-
this.
|
|
1178
|
-
this.
|
|
1179
|
-
this.
|
|
1180
|
-
this.
|
|
1181
|
-
this.
|
|
1182
|
-
this.
|
|
1183
|
-
this.
|
|
1184
|
-
this.
|
|
1185
|
-
this.
|
|
1186
|
-
this.
|
|
1187
|
-
this.
|
|
1188
|
-
this.
|
|
1189
|
-
this.
|
|
1190
|
-
this.
|
|
1191
|
-
this.
|
|
1192
|
-
this.
|
|
1193
|
-
this.
|
|
1194
|
-
this.
|
|
1195
|
-
this.
|
|
1196
|
-
this.
|
|
1197
|
-
this.
|
|
1198
|
-
this.
|
|
1199
|
-
this.
|
|
1200
|
-
this.
|
|
1201
|
-
this.
|
|
1202
|
-
this.
|
|
1203
|
-
this.
|
|
1204
|
-
this.
|
|
1205
|
-
this.
|
|
1206
|
-
this.
|
|
1207
|
-
this.
|
|
1208
|
-
this.
|
|
1209
|
-
this.
|
|
1210
|
-
this.
|
|
1211
|
-
this.
|
|
1212
|
-
this.
|
|
1213
|
-
this.
|
|
1214
|
-
this.
|
|
1215
|
-
this.
|
|
1216
|
-
this.
|
|
1217
|
-
this.
|
|
1218
|
-
this.
|
|
1219
|
-
this.
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
*
|
|
1238
|
-
*
|
|
1239
|
-
* @
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
Source.prototype.
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
};
|
|
1313
|
-
|
|
1314
|
-
return Source;
|
|
1315
|
-
});
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
*
|
|
4
|
+
* Defines the {@link source} class.
|
|
5
|
+
*
|
|
6
|
+
* @module source
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
define([
|
|
10
|
+
'../utils'
|
|
11
|
+
], function(Utils) {
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
function validateSource(peaks, options, context) {
|
|
15
|
+
if (!Utils.isValidTime(options.startTime)) {
|
|
16
|
+
throw new TypeError('peaks.sources.' + context + ': startTime should be a valid number');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!Utils.isValidTime(options.endTime)) {
|
|
20
|
+
throw new TypeError('peaks.sources.' + context + ': endTime should be a valid number');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (!Utils.isValidTime(options.duration) || options.duration <= 0) {
|
|
24
|
+
options.duration = 0;
|
|
25
|
+
}
|
|
26
|
+
else if (options.duration < peaks.options.minSourceSize) {
|
|
27
|
+
options.duration = peaks.options.minSourceSize;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
options.duration = Utils.roundTime(options.duration);
|
|
31
|
+
|
|
32
|
+
if (options.startTime < 0) {
|
|
33
|
+
throw new RangeError('peaks.sources.' + context + ': startTime should be positive');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (options.endTime < 0) {
|
|
37
|
+
throw new RangeError('peaks.sources.' + context + ': endTime should be positive');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (options.endTime <= options.startTime) {
|
|
41
|
+
throw new RangeError(
|
|
42
|
+
'peaks.sources.' + context + ': endTime should be greater than startTime'
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (options.endTime - options.startTime < peaks.options.minSourceSize) {
|
|
47
|
+
options.endTime = options.startTime + peaks.options.minSourceSize;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!Utils.isValidTime(options.mediaStartTime) || options.mediaStartTime < 0) {
|
|
51
|
+
options.mediaStartTime = 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!Utils.isValidTime(options.mediaEndTime)
|
|
55
|
+
|| (options.mediaEndTime < options.mediaStartTime)
|
|
56
|
+
|| (options.mediaEndTime - options.mediaStartTime !== options.endTime - options.startTime)) {
|
|
57
|
+
options.mediaEndTime = options.mediaStartTime + (options.endTime - options.startTime);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (options.duration && options.mediaEndTime > options.duration) {
|
|
61
|
+
var timeWidth = options.mediaEndTime - options.mediaStartTime;
|
|
62
|
+
|
|
63
|
+
options.mediaEndTime = options.duration;
|
|
64
|
+
if (options.duration > timeWidth) {
|
|
65
|
+
options.mediaStartTime = options.mediaEndTime - timeWidth;
|
|
66
|
+
options.endTime = options.startTime + timeWidth;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
options.mediaStartTime = 0;
|
|
70
|
+
options.endTime = options.startTime + options.duration;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
options.startTime = Utils.roundTime(options.startTime);
|
|
75
|
+
options.endTime = Utils.roundTime(options.endTime);
|
|
76
|
+
options.mediaStartTime = Utils.roundTime(options.mediaStartTime);
|
|
77
|
+
options.mediaEndTime = Utils.roundTime(options.mediaEndTime);
|
|
78
|
+
|
|
79
|
+
if (Utils.isNullOrUndefined(options.title)) {
|
|
80
|
+
options.title = '';
|
|
81
|
+
}
|
|
82
|
+
else if (!Utils.isString(options.title)) {
|
|
83
|
+
throw new TypeError('peaks.sources.' + context + ': title must be a string');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (Utils.isNullOrUndefined(options.titleAlignments)) {
|
|
87
|
+
options.titleAlignments = [];
|
|
88
|
+
}
|
|
89
|
+
else if (!Array.isArray(options.titleAlignments)) {
|
|
90
|
+
throw new TypeError('peaks.sources.' + context + ': titleAlignments must be an array');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (Utils.isNullOrUndefined(options.url)) {
|
|
94
|
+
options.url = '';
|
|
95
|
+
}
|
|
96
|
+
else if (!Utils.isString(options.url)) {
|
|
97
|
+
throw new TypeError('peaks.sources.' + context + ': url must be a string');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (Utils.isNullOrUndefined(options.previewUrl)) {
|
|
101
|
+
options.previewUrl = '';
|
|
102
|
+
}
|
|
103
|
+
else if (!Utils.isString(options.previewUrl)) {
|
|
104
|
+
throw new TypeError('peaks.sources.' + context + ': previewUrl must be a string');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (Utils.isNullOrUndefined(options.binaryUrl)) {
|
|
108
|
+
options.binaryUrl = '';
|
|
109
|
+
}
|
|
110
|
+
else if (!Utils.isString(options.binaryUrl)) {
|
|
111
|
+
throw new TypeError('peaks.sources.' + context + ': binaryUrl must be a string');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (!Utils.isValidColor(options.color)) {
|
|
115
|
+
options.color = peaks.options.zoomWaveformColor;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (!Utils.isValidColor(options.backgroundColor)) {
|
|
119
|
+
throw new TypeError(
|
|
120
|
+
'peaks.sources.' + context + ': backgroundColor should be a valid CSS color'
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (Utils.isNullOrUndefined(options.selectedBackgroundColor)) {
|
|
125
|
+
options.selectedBackgroundColor = options.backgroundColor;
|
|
126
|
+
}
|
|
127
|
+
else if (!Utils.isValidColor(options.selectedBackgroundColor)) {
|
|
128
|
+
throw new TypeError(
|
|
129
|
+
'peaks.sources.' + context + ': selectedBackgroundColor should be a valid CSS color'
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (Utils.isNullOrUndefined(options.hoverBackgroundColor)) {
|
|
134
|
+
options.hoverBackgroundColor = Utils.shadeColor(options.backgroundColor, 30);
|
|
135
|
+
}
|
|
136
|
+
else if (!Utils.isValidColor(options.hoverBackgroundColor)) {
|
|
137
|
+
throw new TypeError(
|
|
138
|
+
'peaks.sources.' + context + ': hoverBackgroundColor should be a valid CSS color'
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (Utils.isNullOrUndefined(options.borderColor)) {
|
|
143
|
+
options.borderColor = options.color;
|
|
144
|
+
}
|
|
145
|
+
else if (!Utils.isValidColor(options.borderColor)) {
|
|
146
|
+
throw new TypeError(
|
|
147
|
+
'peaks.sources.' + context + ': borderColor should be a valid CSS color'
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (Utils.isNullOrUndefined(options.selectedBorderColor)) {
|
|
152
|
+
options.selectedBorderColor = Utils.shadeColor(options.borderColor, 30);
|
|
153
|
+
}
|
|
154
|
+
else if (!Utils.isValidColor(options.selectedBorderColor)) {
|
|
155
|
+
throw new TypeError(
|
|
156
|
+
'peaks.sources.' + context + ': selectedBorderColor should be a valid CSS color'
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (Utils.isNullOrUndefined(options.warningColor)) {
|
|
161
|
+
options.warningColor = null;
|
|
162
|
+
}
|
|
163
|
+
else if (!Utils.isValidColor(options.warningColor)) {
|
|
164
|
+
throw new TypeError(
|
|
165
|
+
'peaks.sources.' + context + ': warningColor should be a valid CSS color'
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (Utils.isNullOrUndefined(options.warningWidth)) {
|
|
170
|
+
options.warningWidth = 10;
|
|
171
|
+
}
|
|
172
|
+
else if (!Utils.isNumber(options.warningWidth)) {
|
|
173
|
+
throw new TypeError('peaks.sources.' + context + ': warningWidth should be a number');
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (Utils.isNullOrUndefined(options.volumeSliderColor)) {
|
|
177
|
+
options.volumeSliderColor = '#000000';
|
|
178
|
+
}
|
|
179
|
+
else if (!Utils.isValidColor(options.volumeSliderColor)) {
|
|
180
|
+
throw new TypeError(
|
|
181
|
+
'peaks.sources.' + context + ': volumeSliderColor should be a valid CSS color'
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (Utils.isNullOrUndefined(options.volumeSliderWidth)) {
|
|
186
|
+
options.volumeSliderWidth = 2;
|
|
187
|
+
}
|
|
188
|
+
else if (!Utils.isNumber(options.volumeSliderWidth)) {
|
|
189
|
+
throw new TypeError('peaks.sources.' + context + ': volumeSliderWidth should be a number');
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (Utils.isNullOrUndefined(options.volumeSliderDraggingWidth)) {
|
|
193
|
+
options.volumeSliderDraggingWidth = options.volumeSliderWidth;
|
|
194
|
+
}
|
|
195
|
+
else if (!Utils.isNumber(options.volumeSliderDraggingWidth)) {
|
|
196
|
+
throw new TypeError(
|
|
197
|
+
'peaks.sources.' + context + ': volumeSliderDraggingWidth should be a number'
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (Utils.isNullOrUndefined(options.textFont)) {
|
|
202
|
+
options.textFont = 'Arial';
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (Utils.isNullOrUndefined(options.textFontSize)) {
|
|
206
|
+
options.textFontSize = 12;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (Utils.isNullOrUndefined(options.textColor)) {
|
|
210
|
+
options.textColor = '#000000';
|
|
211
|
+
}
|
|
212
|
+
else if (!Utils.isValidColor(options.textColor)) {
|
|
213
|
+
throw new TypeError('peaks.sources.' + context + ': textColor should be a valid CSS color');
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (!Utils.isNullOrUndefined(options.textBackgroundColor)
|
|
217
|
+
&& !Utils.isValidColor(options.textBackgroundColor)) {
|
|
218
|
+
throw new TypeError(
|
|
219
|
+
'peaks.sources.' + context + ': textBackgroundColor should be a valid CSS color'
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (Utils.isNullOrUndefined(options.textPosition)) {
|
|
224
|
+
options.textPosition = 'bottom';
|
|
225
|
+
}
|
|
226
|
+
else if (!Utils.isString(options.textPosition)) {
|
|
227
|
+
throw new TypeError('peaks.sources.' + context + ': textPosition must be a string');
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (Utils.isNullOrUndefined(options.textAutoScroll)) {
|
|
231
|
+
options.textAutoScroll = false;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (Utils.isNullOrUndefined(options.borderWidth)) {
|
|
235
|
+
options.borderWidth = 0;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (Utils.isNullOrUndefined(options.wrapped)) {
|
|
239
|
+
options.wrapped = false;
|
|
240
|
+
}
|
|
241
|
+
else if (!Utils.isBoolean(options.wrapped)) {
|
|
242
|
+
throw new TypeError('peaks.sources.' + context + ': wrapped must be a boolean');
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (Utils.isNullOrUndefined(options.draggable)) {
|
|
246
|
+
options.draggable = true;
|
|
247
|
+
}
|
|
248
|
+
else if (!Utils.isBoolean(options.draggable)) {
|
|
249
|
+
throw new TypeError('peaks.sources.' + context + ': draggable must be a boolean');
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (Utils.isNullOrUndefined(options.orderable)) {
|
|
253
|
+
options.orderable = true;
|
|
254
|
+
}
|
|
255
|
+
else if (!Utils.isBoolean(options.orderable)) {
|
|
256
|
+
throw new TypeError('peaks.sources.' + context + ': orderable must be a boolean');
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (Utils.isNullOrUndefined(options.resizable)) {
|
|
260
|
+
options.resizable = true;
|
|
261
|
+
}
|
|
262
|
+
else if (!Utils.isBoolean(options.resizable)) {
|
|
263
|
+
throw new TypeError('peaks.sources.' + context + ': resizable must be a boolean');
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (Utils.isNullOrUndefined(options.cuttable)) {
|
|
267
|
+
options.cuttable = true;
|
|
268
|
+
}
|
|
269
|
+
else if (!Utils.isBoolean(options.cuttable)) {
|
|
270
|
+
throw new TypeError('peaks.sources.' + context + ': cuttable must be a boolean');
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (Utils.isNullOrUndefined(options.deletable)) {
|
|
274
|
+
options.deletable = true;
|
|
275
|
+
}
|
|
276
|
+
else if (!Utils.isBoolean(options.deletable)) {
|
|
277
|
+
throw new TypeError('peaks.sources.' + context + ': deletable must be a boolean');
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (Utils.isNullOrUndefined(options.wrapping)) {
|
|
281
|
+
options.wrapping = 'both';
|
|
282
|
+
}
|
|
283
|
+
else if (!Utils.isString(options.wrapping)) {
|
|
284
|
+
throw new TypeError('peaks.sources.' + context + ': wrapping must be a string');
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (Utils.isNullOrUndefined(options.previewHeight)) {
|
|
288
|
+
options.previewHeight = 0;
|
|
289
|
+
}
|
|
290
|
+
else if (!Utils.isNumber(options.previewHeight)) {
|
|
291
|
+
throw new TypeError('peaks.sources.' + context + ': previewHeight must be a number');
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (Utils.isNullOrUndefined(options.binaryHeight)) {
|
|
295
|
+
options.binaryHeight = 0;
|
|
296
|
+
}
|
|
297
|
+
else if (!Utils.isNumber(options.binaryHeight)) {
|
|
298
|
+
throw new TypeError('peaks.sources.' + context + ': binaryHeight must be a number');
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (options.previewUrl && !options.previewHeight) {
|
|
302
|
+
if (options.binaryHeight) {
|
|
303
|
+
options.previewHeight = Math.max(peaks.options.lineHeight - options.binaryHeight, 0);
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
options.previewHeight = peaks.options.lineHeight / 2;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (options.binaryUrl && !options.binaryHeight) {
|
|
311
|
+
options.binaryHeight = Math.max(peaks.options.lineHeight - options.previewHeight, 0);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (options.wrapping === 'reduced') {
|
|
315
|
+
options.wrapped = true;
|
|
316
|
+
}
|
|
317
|
+
else if (options.wrapping === 'complete') {
|
|
318
|
+
options.wrapped = false;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (Utils.isNullOrUndefined(options.indicators)) {
|
|
322
|
+
options.indicators = [];
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (Utils.isNullOrUndefined(options.markers)) {
|
|
326
|
+
options.markers = [];
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (Utils.isNullOrUndefined(options.buttons)) {
|
|
330
|
+
options.buttons = [];
|
|
331
|
+
}
|
|
332
|
+
else if (!Array.isArray(options.buttons)) {
|
|
333
|
+
throw new TypeError('peaks.sources.' + context + ': buttons must be an array');
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (Utils.isNullOrUndefined(options.markerColor)
|
|
337
|
+
|| !Utils.isValidColor(options.markerColor)) {
|
|
338
|
+
options.markerColor = options.color;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (Utils.isNullOrUndefined(options.markerWidth)) {
|
|
342
|
+
options.markerWidth = 2;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (!Utils.isNullOrUndefined(options.volumeRange)) {
|
|
346
|
+
if (!Array.isArray(options.volumeRange)
|
|
347
|
+
|| options.volumeRange.length !== 2
|
|
348
|
+
|| !options.volumeRange.every(Utils.isNumber)) {
|
|
349
|
+
throw new TypeError('peaks.sources.' + context + ': volumeRange must be an array of two numbers');
|
|
350
|
+
}
|
|
351
|
+
else if (options.volumeRange[0] > options.volumeRange[1]) {
|
|
352
|
+
throw new RangeError('peaks.sources.' + context + ': volumeRange[0] should be less than volumeRange[1]');
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (!Utils.isNullOrUndefined(options.volume)) {
|
|
357
|
+
if (!Utils.isNumber(options.volume)) {
|
|
358
|
+
throw new TypeError('peaks.sources.' + context + ': volume must be a number');
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
options.volume = Utils.clamp(options.volume, options.volumeRange[0], options.volumeRange[1]);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (Utils.isNullOrUndefined(options.loading)) {
|
|
366
|
+
options.loading = false;
|
|
367
|
+
}
|
|
368
|
+
else if (!Utils.isBoolean(options.loading)) {
|
|
369
|
+
throw new TypeError('peaks.sources.' + context + ': loading must be a boolean');
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* A source is an external media resource, represented on the timeline.
|
|
375
|
+
*
|
|
376
|
+
* @class
|
|
377
|
+
* @alias Source
|
|
378
|
+
*
|
|
379
|
+
* @param {Peaks} peaks A reference to the Peaks instance.
|
|
380
|
+
* @param {String} id A unique identifier for the source.
|
|
381
|
+
* @param {String} lineId The identifier of the line this source belongs to.
|
|
382
|
+
* @param {String} originId The original identifier of the source before any cuts.
|
|
383
|
+
* @param {String} elementId The HTML element identifier associated with this source.
|
|
384
|
+
* @param {String} title Name of the source.
|
|
385
|
+
* @param {Array<Object>} titleAlignments Array of objects with structure:
|
|
386
|
+
* [{text: String, start: Number, end: Number}, ...]
|
|
387
|
+
* @param {String} url Reference to the media element this source is representing.
|
|
388
|
+
* @param {String} previewUrl URL for preview media content.
|
|
389
|
+
* @param {String} binaryUrl URL for binary data associated with the source.
|
|
390
|
+
* @param {String} kind Type/category of the source.
|
|
391
|
+
* @param {String} subkind Sub-category of the source.
|
|
392
|
+
* @param {Number} duration Total duration of the source media, in seconds.
|
|
393
|
+
* @param {Number} startTime Source start time on the timeline, in seconds.
|
|
394
|
+
* @param {Number} endTime Source end time on the timeline, in seconds.
|
|
395
|
+
* @param {Number} mediaStartTime Start time within the source media, in seconds.
|
|
396
|
+
* @param {Number} mediaEndTime End time within the source media, in seconds.
|
|
397
|
+
* @param {String} color Primary color of the source representation.
|
|
398
|
+
* @param {String} backgroundColor Background color of the source.
|
|
399
|
+
* @param {String} borderColor Border color of the source.
|
|
400
|
+
* @param {String} selectedBorderColor Color when the source is selected.
|
|
401
|
+
* @param {String} warningColor Color used for warning states.
|
|
402
|
+
* @param {String} volumeSliderColor Color of the volume slider.
|
|
403
|
+
* @param {Number} volumeSliderWidth Width of the volume slider.
|
|
404
|
+
* @param {Number} volumeSliderDraggingWidth Width of the volume slider when dragging.
|
|
405
|
+
* @param {String} textFont Font family for text display.
|
|
406
|
+
* @param {Number} textFontSize Font size for text display.
|
|
407
|
+
* @param {String} textColor Color of the text.
|
|
408
|
+
* @param {String} textBackgroundColor Background color of the text.
|
|
409
|
+
* @param {String} textPosition Position of text relative to the source.
|
|
410
|
+
* @param {Boolean} textAutoScroll If <code>true</code> text will auto-scroll.
|
|
411
|
+
* @param {Number} borderWidth Width of the source border.
|
|
412
|
+
* @param {Number} borderRadius Radius for rounded corners.
|
|
413
|
+
* @param {Boolean} wrapped If <code>true</code> the source representation will be smaller.
|
|
414
|
+
* @param {Boolean} draggable If <code>true</code> the source can be dragged.
|
|
415
|
+
* @param {Boolean} orderable If <code>true</code> the source can be reordered.
|
|
416
|
+
* @param {Boolean} resizable If <code>true</code> the source can be resized.
|
|
417
|
+
* @param {Boolean} cuttable If <code>true</code> the source can be cut.
|
|
418
|
+
* @param {Boolean} deletable If <code>true</code> the source can be deleted.
|
|
419
|
+
* @param {String} wrapping Wrapping mode for the source display.
|
|
420
|
+
* @param {Number} previewHeight Height of the preview area.
|
|
421
|
+
* @param {Number} binaryHeight Height of the binary data visualization.
|
|
422
|
+
* @param {Array} indicators Array containing indicator data for the source.
|
|
423
|
+
* @param {Array} markers Array containing marker data for the source.
|
|
424
|
+
* @param {Array} buttons Array containing button data for the source.
|
|
425
|
+
* @param {String} markerColor Color of the markers.
|
|
426
|
+
* @param {Number} markerWidth Width of the markers.
|
|
427
|
+
* @param {Number} volume Current volume level of the source.
|
|
428
|
+
* @param {Array<Number>} volumeRange Array containing min and max volume values.
|
|
429
|
+
* @param {Boolean} loading If <code>true</code> the source is currently loading.
|
|
430
|
+
*/
|
|
431
|
+
|
|
432
|
+
function Source(peaks, id, lineId, originId, elementId, title, titleAlignments, url, previewUrl, binaryUrl, kind,
|
|
433
|
+
subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, hoverBackgroundColor,
|
|
434
|
+
selectedBackgroundColor, borderColor, selectedBorderColor, warningColor, warningWidth, volumeSliderColor,
|
|
435
|
+
volumeSliderWidth, volumeSliderDraggingWidth, textFont, textFontSize, textColor, textBackgroundColor, textPosition,
|
|
436
|
+
textAutoScroll, borderWidth, borderRadius, wrapped, draggable, orderable, resizable,
|
|
437
|
+
cuttable, deletable, wrapping, previewHeight, binaryHeight, indicators, markers, buttons, markerColor,
|
|
438
|
+
markerWidth, volume, volumeRange, loading, ...customParams) {
|
|
439
|
+
var opts = {
|
|
440
|
+
title: title,
|
|
441
|
+
titleAlignments: titleAlignments,
|
|
442
|
+
url: url,
|
|
443
|
+
previewUrl: previewUrl,
|
|
444
|
+
binaryUrl: binaryUrl,
|
|
445
|
+
kind: kind,
|
|
446
|
+
subkind: subkind,
|
|
447
|
+
duration: duration,
|
|
448
|
+
startTime: startTime,
|
|
449
|
+
endTime: endTime,
|
|
450
|
+
mediaStartTime: mediaStartTime,
|
|
451
|
+
mediaEndTime: mediaEndTime,
|
|
452
|
+
color: color,
|
|
453
|
+
backgroundColor: backgroundColor,
|
|
454
|
+
hoverBackgroundColor: hoverBackgroundColor,
|
|
455
|
+
selectedBackgroundColor: selectedBackgroundColor,
|
|
456
|
+
borderColor: borderColor,
|
|
457
|
+
selectedBorderColor: selectedBorderColor,
|
|
458
|
+
warningColor: warningColor,
|
|
459
|
+
warningWidth: warningWidth,
|
|
460
|
+
textFont: textFont,
|
|
461
|
+
textFontSize: textFontSize,
|
|
462
|
+
textColor: textColor,
|
|
463
|
+
textBackgroundColor: textBackgroundColor,
|
|
464
|
+
volumeSliderColor: volumeSliderColor,
|
|
465
|
+
volumeSliderWidth: volumeSliderWidth,
|
|
466
|
+
volumeSliderDraggingWidth: volumeSliderDraggingWidth,
|
|
467
|
+
textPosition: textPosition,
|
|
468
|
+
textAutoScroll: textAutoScroll,
|
|
469
|
+
borderWidth: borderWidth,
|
|
470
|
+
borderRadius: borderRadius,
|
|
471
|
+
wrapped: wrapped,
|
|
472
|
+
draggable: draggable,
|
|
473
|
+
orderable: orderable,
|
|
474
|
+
resizable: resizable,
|
|
475
|
+
cuttable: cuttable,
|
|
476
|
+
deletable: deletable,
|
|
477
|
+
wrapping: wrapping,
|
|
478
|
+
previewHeight: previewHeight,
|
|
479
|
+
binaryHeight: binaryHeight,
|
|
480
|
+
indicators: indicators,
|
|
481
|
+
markers: markers,
|
|
482
|
+
buttons: buttons,
|
|
483
|
+
markerColor: markerColor,
|
|
484
|
+
markerWidth: markerWidth,
|
|
485
|
+
volume: volume,
|
|
486
|
+
volumeRange: volumeRange,
|
|
487
|
+
loading: loading
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
validateSource(peaks, opts, 'add()');
|
|
491
|
+
|
|
492
|
+
this._peaks = peaks;
|
|
493
|
+
this._id = id;
|
|
494
|
+
this._lineId = lineId;
|
|
495
|
+
this._originId = originId || id;
|
|
496
|
+
this._elementId = elementId;
|
|
497
|
+
this._title = opts.title;
|
|
498
|
+
this._titleAlignments = opts.titleAlignments;
|
|
499
|
+
this._url = opts.url;
|
|
500
|
+
this._previewUrl = opts.previewUrl;
|
|
501
|
+
this._binaryUrl = opts.binaryUrl;
|
|
502
|
+
this._kind = opts.kind;
|
|
503
|
+
this._subkind = opts.subkind;
|
|
504
|
+
this._duration = opts.duration;
|
|
505
|
+
this._startTime = opts.startTime;
|
|
506
|
+
this._endTime = opts.endTime;
|
|
507
|
+
this._mediaStartTime = opts.mediaStartTime;
|
|
508
|
+
this._mediaEndTime = opts.mediaEndTime;
|
|
509
|
+
this._color = opts.color;
|
|
510
|
+
this._backgroundColor = opts.backgroundColor;
|
|
511
|
+
this._hoverBackgroundColor = opts.hoverBackgroundColor;
|
|
512
|
+
this._selectedBackgroundColor = opts.selectedBackgroundColor;
|
|
513
|
+
this._borderColor = opts.borderColor;
|
|
514
|
+
this._selectedBorderColor = opts.selectedBorderColor;
|
|
515
|
+
this._warningColor = opts.warningColor;
|
|
516
|
+
this._warningWidth = opts.warningWidth;
|
|
517
|
+
this._volumeSliderColor = opts.volumeSliderColor;
|
|
518
|
+
this._volumeSliderWidth = opts.volumeSliderWidth;
|
|
519
|
+
this._volumeSliderDraggingWidth = opts.volumeSliderDraggingWidth;
|
|
520
|
+
this._textFont = opts.textFont;
|
|
521
|
+
this._textFontSize = opts.textFontSize;
|
|
522
|
+
this._textColor = opts.textColor;
|
|
523
|
+
this._textBackgroundColor = opts.textBackgroundColor;
|
|
524
|
+
this._textPosition = opts.textPosition;
|
|
525
|
+
this._textAutoScroll = opts.textAutoScroll;
|
|
526
|
+
this._borderWidth = opts.borderWidth;
|
|
527
|
+
this._borderRadius = opts.borderRadius;
|
|
528
|
+
this._wrapped = opts.wrapped;
|
|
529
|
+
this._draggable = opts.draggable;
|
|
530
|
+
this._orderable = opts.orderable;
|
|
531
|
+
this._resizable = opts.resizable;
|
|
532
|
+
this._cuttable = opts.cuttable;
|
|
533
|
+
this._deletable = opts.deletable;
|
|
534
|
+
this._wrapping = opts.wrapping;
|
|
535
|
+
this._previewHeight = opts.previewHeight;
|
|
536
|
+
this._binaryHeight = opts.binaryHeight;
|
|
537
|
+
this._indicators = opts.indicators;
|
|
538
|
+
this._markers = opts.markers;
|
|
539
|
+
this._buttons = opts.buttons;
|
|
540
|
+
this._markerColor = opts.markerColor;
|
|
541
|
+
this._markerWidth = opts.markerWidth;
|
|
542
|
+
this._volume = opts.volume;
|
|
543
|
+
this._volumeRange = opts.volumeRange;
|
|
544
|
+
this._loading = opts.loading;
|
|
545
|
+
this._minSize = peaks.options.minSourceSize;
|
|
546
|
+
this._selected = false;
|
|
547
|
+
|
|
548
|
+
for (var i = 0; i < customParams.length; i += 2) {
|
|
549
|
+
var key = customParams[i];
|
|
550
|
+
var value = customParams[i + 1];
|
|
551
|
+
|
|
552
|
+
if (key && key.startsWith('custom_')) {
|
|
553
|
+
this[key] = value;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
Object.defineProperties(Source.prototype, {
|
|
559
|
+
id: {
|
|
560
|
+
enumerable: true,
|
|
561
|
+
get: function() {
|
|
562
|
+
return this._id;
|
|
563
|
+
}
|
|
564
|
+
},
|
|
565
|
+
lineId: {
|
|
566
|
+
enumerable: true,
|
|
567
|
+
get: function() {
|
|
568
|
+
return this._lineId;
|
|
569
|
+
},
|
|
570
|
+
|
|
571
|
+
set: function(lineId) {
|
|
572
|
+
this._lineId = lineId;
|
|
573
|
+
}
|
|
574
|
+
},
|
|
575
|
+
originId: {
|
|
576
|
+
enumerable: true,
|
|
577
|
+
get: function() {
|
|
578
|
+
return this._originId;
|
|
579
|
+
}
|
|
580
|
+
},
|
|
581
|
+
elementId: {
|
|
582
|
+
enumerable: true,
|
|
583
|
+
get: function() {
|
|
584
|
+
return this._elementId;
|
|
585
|
+
}
|
|
586
|
+
},
|
|
587
|
+
title: {
|
|
588
|
+
enumerable: true,
|
|
589
|
+
get: function() {
|
|
590
|
+
return this._title;
|
|
591
|
+
},
|
|
592
|
+
|
|
593
|
+
set: function(title) {
|
|
594
|
+
this._title = title;
|
|
595
|
+
}
|
|
596
|
+
},
|
|
597
|
+
titleAlignments: {
|
|
598
|
+
enumerable: true,
|
|
599
|
+
get: function() {
|
|
600
|
+
return this._titleAlignments;
|
|
601
|
+
}
|
|
602
|
+
},
|
|
603
|
+
url: {
|
|
604
|
+
enumerable: true,
|
|
605
|
+
get: function() {
|
|
606
|
+
return this._url;
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
previewUrl: {
|
|
610
|
+
enumerable: true,
|
|
611
|
+
get: function() {
|
|
612
|
+
return this._previewUrl;
|
|
613
|
+
}
|
|
614
|
+
},
|
|
615
|
+
binaryUrl: {
|
|
616
|
+
enumerable: true,
|
|
617
|
+
get: function() {
|
|
618
|
+
return this._binaryUrl;
|
|
619
|
+
}
|
|
620
|
+
},
|
|
621
|
+
kind: {
|
|
622
|
+
enumerable: true,
|
|
623
|
+
get: function() {
|
|
624
|
+
return this._kind;
|
|
625
|
+
},
|
|
626
|
+
|
|
627
|
+
set: function(kind) {
|
|
628
|
+
this._kind = kind;
|
|
629
|
+
}
|
|
630
|
+
},
|
|
631
|
+
subkind: {
|
|
632
|
+
enumerable: true,
|
|
633
|
+
get: function() {
|
|
634
|
+
return this._subkind;
|
|
635
|
+
},
|
|
636
|
+
|
|
637
|
+
set: function(subkind) {
|
|
638
|
+
this._subkind = subkind;
|
|
639
|
+
}
|
|
640
|
+
},
|
|
641
|
+
duration: {
|
|
642
|
+
enumerable: true,
|
|
643
|
+
get: function() {
|
|
644
|
+
return this._duration;
|
|
645
|
+
}
|
|
646
|
+
},
|
|
647
|
+
startTime: {
|
|
648
|
+
enumerable: true,
|
|
649
|
+
get: function() {
|
|
650
|
+
return this._startTime;
|
|
651
|
+
}
|
|
652
|
+
},
|
|
653
|
+
endTime: {
|
|
654
|
+
enumerable: true,
|
|
655
|
+
get: function() {
|
|
656
|
+
return this._endTime;
|
|
657
|
+
}
|
|
658
|
+
},
|
|
659
|
+
mediaStartTime: {
|
|
660
|
+
enumerable: true,
|
|
661
|
+
get: function() {
|
|
662
|
+
return this._mediaStartTime;
|
|
663
|
+
},
|
|
664
|
+
|
|
665
|
+
set: function(mediaStartTime) {
|
|
666
|
+
this._mediaStartTime = mediaStartTime;
|
|
667
|
+
}
|
|
668
|
+
},
|
|
669
|
+
mediaEndTime: {
|
|
670
|
+
enumerable: true,
|
|
671
|
+
get: function() {
|
|
672
|
+
return this._mediaEndTime;
|
|
673
|
+
},
|
|
674
|
+
|
|
675
|
+
set: function(mediaEndTime) {
|
|
676
|
+
this._mediaEndTime = mediaEndTime;
|
|
677
|
+
}
|
|
678
|
+
},
|
|
679
|
+
color: {
|
|
680
|
+
enumerable: true,
|
|
681
|
+
get: function() {
|
|
682
|
+
return this._color;
|
|
683
|
+
},
|
|
684
|
+
|
|
685
|
+
set: function(color) {
|
|
686
|
+
this._color = color;
|
|
687
|
+
}
|
|
688
|
+
},
|
|
689
|
+
backgroundColor: {
|
|
690
|
+
enumerable: true,
|
|
691
|
+
get: function() {
|
|
692
|
+
return this._backgroundColor;
|
|
693
|
+
},
|
|
694
|
+
|
|
695
|
+
set: function(backgroundColor) {
|
|
696
|
+
this._backgroundColor = backgroundColor;
|
|
697
|
+
}
|
|
698
|
+
},
|
|
699
|
+
hoverBackgroundColor: {
|
|
700
|
+
enumerable: true,
|
|
701
|
+
get: function() {
|
|
702
|
+
return this._hoverBackgroundColor;
|
|
703
|
+
},
|
|
704
|
+
|
|
705
|
+
set: function(hoverBackgroundColor) {
|
|
706
|
+
this._hoverBackgroundColor = hoverBackgroundColor;
|
|
707
|
+
}
|
|
708
|
+
},
|
|
709
|
+
selectedBackgroundColor: {
|
|
710
|
+
enumerable: true,
|
|
711
|
+
get: function() {
|
|
712
|
+
return this._selectedBackgroundColor;
|
|
713
|
+
},
|
|
714
|
+
|
|
715
|
+
set: function(selectedBackgroundColor) {
|
|
716
|
+
this._selectedBackgroundColor = selectedBackgroundColor;
|
|
717
|
+
}
|
|
718
|
+
},
|
|
719
|
+
borderColor: {
|
|
720
|
+
enumerable: true,
|
|
721
|
+
get: function() {
|
|
722
|
+
return this._borderColor;
|
|
723
|
+
},
|
|
724
|
+
|
|
725
|
+
set: function(borderColor) {
|
|
726
|
+
this._borderColor = borderColor;
|
|
727
|
+
}
|
|
728
|
+
},
|
|
729
|
+
selectedBorderColor: {
|
|
730
|
+
enumerable: true,
|
|
731
|
+
get: function() {
|
|
732
|
+
return this._selectedBorderColor;
|
|
733
|
+
},
|
|
734
|
+
|
|
735
|
+
set: function(selectedBorderColor) {
|
|
736
|
+
this._selectedBorderColor = selectedBorderColor;
|
|
737
|
+
}
|
|
738
|
+
},
|
|
739
|
+
warningColor: {
|
|
740
|
+
enumerable: true,
|
|
741
|
+
get: function() {
|
|
742
|
+
return this._warningColor;
|
|
743
|
+
},
|
|
744
|
+
|
|
745
|
+
set: function(warningColor) {
|
|
746
|
+
this._warningColor = warningColor;
|
|
747
|
+
}
|
|
748
|
+
},
|
|
749
|
+
warningWidth: {
|
|
750
|
+
enumerable: true,
|
|
751
|
+
get: function() {
|
|
752
|
+
return this._warningWidth;
|
|
753
|
+
},
|
|
754
|
+
|
|
755
|
+
set: function(warningWidth) {
|
|
756
|
+
this._warningWidth = warningWidth;
|
|
757
|
+
}
|
|
758
|
+
},
|
|
759
|
+
volumeSliderColor: {
|
|
760
|
+
enumerable: true,
|
|
761
|
+
get: function() {
|
|
762
|
+
return this._volumeSliderColor;
|
|
763
|
+
}
|
|
764
|
+
},
|
|
765
|
+
volumeSliderWidth: {
|
|
766
|
+
enumerable: true,
|
|
767
|
+
get: function() {
|
|
768
|
+
return this._volumeSliderWidth;
|
|
769
|
+
}
|
|
770
|
+
},
|
|
771
|
+
volumeSliderDraggingWidth: {
|
|
772
|
+
enumerable: true,
|
|
773
|
+
get: function() {
|
|
774
|
+
return this._volumeSliderDraggingWidth;
|
|
775
|
+
}
|
|
776
|
+
},
|
|
777
|
+
textFont: {
|
|
778
|
+
enumerable: true,
|
|
779
|
+
get: function() {
|
|
780
|
+
return this._textFont;
|
|
781
|
+
},
|
|
782
|
+
|
|
783
|
+
set: function(textFont) {
|
|
784
|
+
this._textFont = textFont;
|
|
785
|
+
}
|
|
786
|
+
},
|
|
787
|
+
textFontSize: {
|
|
788
|
+
enumerable: true,
|
|
789
|
+
get: function() {
|
|
790
|
+
return this._textFontSize;
|
|
791
|
+
},
|
|
792
|
+
|
|
793
|
+
set: function(textFontSize) {
|
|
794
|
+
this._textFontSize = textFontSize;
|
|
795
|
+
}
|
|
796
|
+
},
|
|
797
|
+
textColor: {
|
|
798
|
+
enumerable: true,
|
|
799
|
+
get: function() {
|
|
800
|
+
return this._textColor;
|
|
801
|
+
},
|
|
802
|
+
|
|
803
|
+
set: function(textColor) {
|
|
804
|
+
this._textColor = textColor;
|
|
805
|
+
}
|
|
806
|
+
},
|
|
807
|
+
textBackgroundColor: {
|
|
808
|
+
enumerable: true,
|
|
809
|
+
get: function() {
|
|
810
|
+
return this._textBackgroundColor;
|
|
811
|
+
},
|
|
812
|
+
|
|
813
|
+
set: function(textBackgroundColor) {
|
|
814
|
+
this._textBackgroundColor = textBackgroundColor;
|
|
815
|
+
}
|
|
816
|
+
},
|
|
817
|
+
textPosition: {
|
|
818
|
+
enumerable: true,
|
|
819
|
+
get: function() {
|
|
820
|
+
return this._textPosition;
|
|
821
|
+
},
|
|
822
|
+
|
|
823
|
+
set: function(textPosition) {
|
|
824
|
+
this._textPosition = textPosition;
|
|
825
|
+
}
|
|
826
|
+
},
|
|
827
|
+
textAutoScroll: {
|
|
828
|
+
enumerable: true,
|
|
829
|
+
get: function() {
|
|
830
|
+
return this._textAutoScroll;
|
|
831
|
+
},
|
|
832
|
+
|
|
833
|
+
set: function(textAutoScroll) {
|
|
834
|
+
this._textAutoScroll = textAutoScroll;
|
|
835
|
+
}
|
|
836
|
+
},
|
|
837
|
+
borderWidth: {
|
|
838
|
+
enumerable: true,
|
|
839
|
+
get: function() {
|
|
840
|
+
return this._borderWidth;
|
|
841
|
+
},
|
|
842
|
+
|
|
843
|
+
set: function(borderWidth) {
|
|
844
|
+
this._borderWidth = borderWidth;
|
|
845
|
+
}
|
|
846
|
+
},
|
|
847
|
+
borderRadius: {
|
|
848
|
+
enumerable: true,
|
|
849
|
+
get: function() {
|
|
850
|
+
return this._borderRadius;
|
|
851
|
+
},
|
|
852
|
+
|
|
853
|
+
set: function(borderRadius) {
|
|
854
|
+
this._borderRadius = borderRadius;
|
|
855
|
+
}
|
|
856
|
+
},
|
|
857
|
+
wrapped: {
|
|
858
|
+
enumerable: true,
|
|
859
|
+
get: function() {
|
|
860
|
+
return this._wrapped;
|
|
861
|
+
},
|
|
862
|
+
|
|
863
|
+
set: function(wrapped) {
|
|
864
|
+
this._wrapped = wrapped;
|
|
865
|
+
}
|
|
866
|
+
},
|
|
867
|
+
segments: {
|
|
868
|
+
enumerable: true,
|
|
869
|
+
get: function() {
|
|
870
|
+
return this._segments;
|
|
871
|
+
}
|
|
872
|
+
},
|
|
873
|
+
draggable: {
|
|
874
|
+
enumerable: true,
|
|
875
|
+
get: function() {
|
|
876
|
+
return this._draggable;
|
|
877
|
+
}
|
|
878
|
+
},
|
|
879
|
+
orderable: {
|
|
880
|
+
enumerable: true,
|
|
881
|
+
get: function() {
|
|
882
|
+
return this._orderable;
|
|
883
|
+
}
|
|
884
|
+
},
|
|
885
|
+
resizable: {
|
|
886
|
+
enumerable: true,
|
|
887
|
+
get: function() {
|
|
888
|
+
return this._resizable;
|
|
889
|
+
}
|
|
890
|
+
},
|
|
891
|
+
cuttable: {
|
|
892
|
+
enumerable: true,
|
|
893
|
+
get: function() {
|
|
894
|
+
return this._cuttable;
|
|
895
|
+
}
|
|
896
|
+
},
|
|
897
|
+
deletable: {
|
|
898
|
+
enumerable: true,
|
|
899
|
+
get: function() {
|
|
900
|
+
return this._deletable;
|
|
901
|
+
}
|
|
902
|
+
},
|
|
903
|
+
wrapping: {
|
|
904
|
+
enumerable: true,
|
|
905
|
+
get: function() {
|
|
906
|
+
return this._wrapping;
|
|
907
|
+
},
|
|
908
|
+
|
|
909
|
+
set: function(wrapping) {
|
|
910
|
+
this._wrapping = wrapping;
|
|
911
|
+
}
|
|
912
|
+
},
|
|
913
|
+
previewHeight: {
|
|
914
|
+
enumerable: true,
|
|
915
|
+
get: function() {
|
|
916
|
+
return this._previewHeight;
|
|
917
|
+
},
|
|
918
|
+
|
|
919
|
+
set: function(previewHeight) {
|
|
920
|
+
this._previewHeight = previewHeight;
|
|
921
|
+
}
|
|
922
|
+
},
|
|
923
|
+
binaryHeight: {
|
|
924
|
+
enumerable: true,
|
|
925
|
+
get: function() {
|
|
926
|
+
return this._binaryHeight;
|
|
927
|
+
},
|
|
928
|
+
|
|
929
|
+
set: function(binaryHeight) {
|
|
930
|
+
this._binaryHeight = binaryHeight;
|
|
931
|
+
}
|
|
932
|
+
},
|
|
933
|
+
indicators: {
|
|
934
|
+
enumerable: true,
|
|
935
|
+
get: function() {
|
|
936
|
+
return this._indicators;
|
|
937
|
+
}
|
|
938
|
+
},
|
|
939
|
+
markers: {
|
|
940
|
+
enumerable: true,
|
|
941
|
+
get: function() {
|
|
942
|
+
return this._markers;
|
|
943
|
+
}
|
|
944
|
+
},
|
|
945
|
+
buttons: {
|
|
946
|
+
enumerable: true,
|
|
947
|
+
get: function() {
|
|
948
|
+
return this._buttons;
|
|
949
|
+
}
|
|
950
|
+
},
|
|
951
|
+
markerColor: {
|
|
952
|
+
enumerable: true,
|
|
953
|
+
get: function() {
|
|
954
|
+
return this._markerColor;
|
|
955
|
+
}
|
|
956
|
+
},
|
|
957
|
+
markerWidth: {
|
|
958
|
+
enumerable: true,
|
|
959
|
+
get: function() {
|
|
960
|
+
return this._markerWidth;
|
|
961
|
+
}
|
|
962
|
+
},
|
|
963
|
+
volume: {
|
|
964
|
+
enumerable: true,
|
|
965
|
+
get: function() {
|
|
966
|
+
return this._volume;
|
|
967
|
+
},
|
|
968
|
+
|
|
969
|
+
set: function(volume) {
|
|
970
|
+
this._volume = volume;
|
|
971
|
+
}
|
|
972
|
+
},
|
|
973
|
+
volumeRange: {
|
|
974
|
+
enumerable: true,
|
|
975
|
+
get: function() {
|
|
976
|
+
return this._volumeRange;
|
|
977
|
+
}
|
|
978
|
+
},
|
|
979
|
+
loading: {
|
|
980
|
+
enumerable: true,
|
|
981
|
+
get: function() {
|
|
982
|
+
return this._loading;
|
|
983
|
+
}
|
|
984
|
+
},
|
|
985
|
+
minSize: {
|
|
986
|
+
enumerable: true,
|
|
987
|
+
get: function() {
|
|
988
|
+
return this._minSize;
|
|
989
|
+
}
|
|
990
|
+
},
|
|
991
|
+
selected: {
|
|
992
|
+
enumerable: true,
|
|
993
|
+
get: function() {
|
|
994
|
+
return this._selected;
|
|
995
|
+
},
|
|
996
|
+
|
|
997
|
+
set: function(selected) {
|
|
998
|
+
this._selected = selected;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
});
|
|
1002
|
+
|
|
1003
|
+
Source.prototype.updateTimes = function(newStartTime, newEndTime) {
|
|
1004
|
+
if (!Utils.isNullOrUndefined(newStartTime)) {
|
|
1005
|
+
if (this._duration && Utils.isNullOrUndefined(newEndTime)) {
|
|
1006
|
+
newStartTime = Utils.roundTime(Math.max(this._endTime - this._duration, newStartTime));
|
|
1007
|
+
}
|
|
1008
|
+
else {
|
|
1009
|
+
newStartTime = Utils.roundTime(newStartTime);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
if (!Utils.isNullOrUndefined(newEndTime)) {
|
|
1014
|
+
if (this._duration && Utils.isNullOrUndefined(newStartTime)) {
|
|
1015
|
+
newEndTime = Utils.roundTime(Math.min(this._startTime + this._duration, newEndTime));
|
|
1016
|
+
}
|
|
1017
|
+
else {
|
|
1018
|
+
newEndTime = Utils.roundTime(newEndTime);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
if ((Utils.isNullOrUndefined(newStartTime) && !Utils.isNullOrUndefined(newEndTime))
|
|
1023
|
+
|| (!Utils.isNullOrUndefined(newStartTime) && Utils.isNullOrUndefined(newEndTime))) {
|
|
1024
|
+
this._updateMediaRange(this._startTime, newStartTime, this._endTime, newEndTime);
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
if (!Utils.isNullOrUndefined(newStartTime)) {
|
|
1028
|
+
this._startTime = newStartTime;
|
|
1029
|
+
}
|
|
1030
|
+
if (!Utils.isNullOrUndefined(newEndTime)) {
|
|
1031
|
+
this._endTime = newEndTime;
|
|
1032
|
+
}
|
|
1033
|
+
};
|
|
1034
|
+
|
|
1035
|
+
Source.prototype._updateMediaRange = function(oldStartTime, newStartTime, oldEndTime,
|
|
1036
|
+
newEndTime) {
|
|
1037
|
+
var startDiff = 0;
|
|
1038
|
+
var endDiff = 0;
|
|
1039
|
+
var upperLimit;
|
|
1040
|
+
|
|
1041
|
+
if (this._duration) {
|
|
1042
|
+
upperLimit = this._duration;
|
|
1043
|
+
}
|
|
1044
|
+
else {
|
|
1045
|
+
upperLimit = Number.POSITIVE_INFINITY;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
if (!Utils.isNullOrUndefined(newStartTime) && !Utils.isNullOrUndefined(oldStartTime)) {
|
|
1049
|
+
startDiff = newStartTime - oldStartTime;
|
|
1050
|
+
}
|
|
1051
|
+
if (!Utils.isNullOrUndefined(newEndTime) && !Utils.isNullOrUndefined(oldEndTime)) {
|
|
1052
|
+
endDiff = newEndTime - oldEndTime;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
var newMediaStartTime = this._mediaStartTime;
|
|
1056
|
+
var newMediaEndTime = this._mediaEndTime;
|
|
1057
|
+
|
|
1058
|
+
if (startDiff) {
|
|
1059
|
+
if (startDiff < 0) {
|
|
1060
|
+
// Try reducing mediaStartTime
|
|
1061
|
+
if (newMediaStartTime > 0) {
|
|
1062
|
+
var minStartTime = newMediaStartTime + startDiff;
|
|
1063
|
+
|
|
1064
|
+
newMediaStartTime = Math.max(0, minStartTime);
|
|
1065
|
+
if (minStartTime < 0) {
|
|
1066
|
+
// Try increasing mediaEndTime
|
|
1067
|
+
newMediaEndTime = Math.min(upperLimit, newMediaEndTime - minStartTime);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
else {
|
|
1071
|
+
// Try increasing mediaEndTime
|
|
1072
|
+
newMediaEndTime = Math.min(upperLimit, newMediaEndTime - startDiff);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
else {
|
|
1076
|
+
// Try increasing mediaStartTime
|
|
1077
|
+
if (newMediaStartTime < upperLimit) {
|
|
1078
|
+
newMediaStartTime = Math.min(upperLimit, newMediaStartTime + startDiff);
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
if (endDiff) {
|
|
1084
|
+
if (endDiff > 0) {
|
|
1085
|
+
// Try increasing mediaEndTime
|
|
1086
|
+
if (newMediaEndTime < upperLimit) {
|
|
1087
|
+
var maxEndTime = newMediaEndTime + endDiff;
|
|
1088
|
+
|
|
1089
|
+
newMediaEndTime = Math.min(upperLimit, maxEndTime);
|
|
1090
|
+
if (maxEndTime > upperLimit) {
|
|
1091
|
+
// Try reducing mediaStartTime
|
|
1092
|
+
newMediaStartTime = Math.max(0, newMediaStartTime - (maxEndTime - upperLimit));
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
else {
|
|
1096
|
+
// Try reducing mediaStartTime
|
|
1097
|
+
newMediaStartTime = Math.max(0, newMediaStartTime - endDiff);
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
else {
|
|
1101
|
+
if (newEndTime - oldStartTime < upperLimit) {
|
|
1102
|
+
if (oldEndTime - oldStartTime > upperLimit) {
|
|
1103
|
+
endDiff += (oldEndTime - oldStartTime) - upperLimit;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
// Try reducing mediaEndTime
|
|
1107
|
+
if (newMediaEndTime > 0) {
|
|
1108
|
+
newMediaEndTime = Math.max(0, newMediaEndTime + endDiff);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
this._mediaStartTime = Utils.roundTime(newMediaStartTime);
|
|
1115
|
+
this._mediaEndTime = Utils.roundTime(newMediaEndTime);
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
Source.prototype.update = function(options) {
|
|
1119
|
+
var opts = {
|
|
1120
|
+
title: this.title,
|
|
1121
|
+
titleAlignments: this.titleAlignments,
|
|
1122
|
+
url: this.url,
|
|
1123
|
+
previewUrl: this.previewUrl,
|
|
1124
|
+
binaryUrl: this.binaryUrl,
|
|
1125
|
+
kind: this.kind,
|
|
1126
|
+
subkind: this.subkind,
|
|
1127
|
+
duration: this.duration,
|
|
1128
|
+
startTime: this.startTime,
|
|
1129
|
+
endTime: this.endTime,
|
|
1130
|
+
mediaStartTime: this.mediaStartTime,
|
|
1131
|
+
mediaEndTime: this.mediaEndTime,
|
|
1132
|
+
color: this.color,
|
|
1133
|
+
backgroundColor: this.backgroundColor,
|
|
1134
|
+
hoverBackgroundColor: this.hoverBackgroundColor,
|
|
1135
|
+
selectedBackgroundColor: this.selectedBackgroundColor,
|
|
1136
|
+
borderColor: this.borderColor,
|
|
1137
|
+
selectedBorderColor: this.selectedBorderColor,
|
|
1138
|
+
warningColor: this.warningColor,
|
|
1139
|
+
warningWidth: this.warningWidth,
|
|
1140
|
+
volumeSliderColor: this.volumeSliderColor,
|
|
1141
|
+
volumeSliderWidth: this.volumeSliderWidth,
|
|
1142
|
+
volumeSliderDraggingWidth: this.volumeSliderDraggingWidth,
|
|
1143
|
+
textFont: this.textFont,
|
|
1144
|
+
textFontSize: this.textFontSize,
|
|
1145
|
+
textColor: this.textColor,
|
|
1146
|
+
textBackgroundColor: this.textBackgroundColor,
|
|
1147
|
+
textPosition: this.textPosition,
|
|
1148
|
+
textAutoScroll: this.textAutoScroll,
|
|
1149
|
+
borderWidth: this.borderWidth,
|
|
1150
|
+
borderRadius: this.borderRadius,
|
|
1151
|
+
wrapped: this.wrapped,
|
|
1152
|
+
draggable: this.draggable,
|
|
1153
|
+
orderable: this.orderable,
|
|
1154
|
+
resizable: this.resizable,
|
|
1155
|
+
cuttable: this.cuttable,
|
|
1156
|
+
deletable: this.deletable,
|
|
1157
|
+
wrapping: this.wrapping,
|
|
1158
|
+
previewHeight: this.previewHeight,
|
|
1159
|
+
binaryHeight: this.binaryHeight,
|
|
1160
|
+
indicators: this.indicators,
|
|
1161
|
+
markers: this.markers,
|
|
1162
|
+
buttons: this.buttons,
|
|
1163
|
+
markerColor: this.markerColor,
|
|
1164
|
+
markerWidth: this.markerWidth,
|
|
1165
|
+
volume: this.volume,
|
|
1166
|
+
volumeRange: this.volumeRange,
|
|
1167
|
+
loading: this.loading
|
|
1168
|
+
};
|
|
1169
|
+
|
|
1170
|
+
Utils.extend(opts, options);
|
|
1171
|
+
|
|
1172
|
+
validateSource(this._peaks, opts, 'update()');
|
|
1173
|
+
|
|
1174
|
+
this._title = opts.title;
|
|
1175
|
+
this._titleAlignments = opts.titleAlignments;
|
|
1176
|
+
this._url = opts.url;
|
|
1177
|
+
this._previewUrl = opts.previewUrl;
|
|
1178
|
+
this._binaryUrl = opts.binaryUrl;
|
|
1179
|
+
this._kind = opts.kind;
|
|
1180
|
+
this._subkind = opts.subkind;
|
|
1181
|
+
this._duration = opts.duration;
|
|
1182
|
+
this._startTime = opts.startTime;
|
|
1183
|
+
this._endTime = opts.endTime;
|
|
1184
|
+
this._mediaStartTime = opts.mediaStartTime;
|
|
1185
|
+
this._mediaEndTime = opts.mediaEndTime;
|
|
1186
|
+
this._color = opts.color;
|
|
1187
|
+
this._backgroundColor = opts.backgroundColor;
|
|
1188
|
+
this._borderColor = opts.borderColor;
|
|
1189
|
+
this._selectedBorderColor = opts.selectedBorderColor;
|
|
1190
|
+
this._warningColor = opts.warningColor;
|
|
1191
|
+
this._warningWidth = opts.warningWidth;
|
|
1192
|
+
this._volumeSliderColor = opts.volumeSliderColor;
|
|
1193
|
+
this._volumeSliderWidth = opts.volumeSliderWidth;
|
|
1194
|
+
this._volumeSliderDraggingWidth = opts.volumeSliderDraggingWidth;
|
|
1195
|
+
this._textFont = opts.textFont;
|
|
1196
|
+
this._textFontSize = opts.textFontSize;
|
|
1197
|
+
this._textColor = opts.textColor;
|
|
1198
|
+
this._textBackgroundColor = opts.textBackgroundColor;
|
|
1199
|
+
this._textPosition = opts.textPosition;
|
|
1200
|
+
this._textAutoScroll = opts.textAutoScroll;
|
|
1201
|
+
this._borderWidth = opts.borderWidth;
|
|
1202
|
+
this._borderRadius = opts.borderRadius;
|
|
1203
|
+
this._wrapped = opts.wrapped;
|
|
1204
|
+
this._draggable = opts.draggable;
|
|
1205
|
+
this._orderable = opts.orderable;
|
|
1206
|
+
this._resizable = opts.resizable;
|
|
1207
|
+
this._cuttable = opts.cuttable;
|
|
1208
|
+
this._deletable = opts.deletable;
|
|
1209
|
+
this._wrapping = opts.wrapping;
|
|
1210
|
+
this._previewHeight = opts.previewHeight;
|
|
1211
|
+
this._binaryHeight = opts.binaryHeight;
|
|
1212
|
+
this._indicators = opts.indicators;
|
|
1213
|
+
this._markers = opts.markers;
|
|
1214
|
+
this._buttons = opts.buttons;
|
|
1215
|
+
this._markerColor = opts.markerColor;
|
|
1216
|
+
this._markerWidth = opts.markerWidth;
|
|
1217
|
+
this._volume = opts.volume;
|
|
1218
|
+
this._volumeRange = opts.volumeRange;
|
|
1219
|
+
this._loading = opts.loading;
|
|
1220
|
+
|
|
1221
|
+
if (options && typeof options === 'object') {
|
|
1222
|
+
for (var key in options) {
|
|
1223
|
+
if (Object.prototype.hasOwnProperty.call(options, key) && key.startsWith('custom_')) {
|
|
1224
|
+
this[key] = options[key];
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
this._peaks.emit('model.source.update', this);
|
|
1230
|
+
};
|
|
1231
|
+
|
|
1232
|
+
/**
|
|
1233
|
+
* Returns <code>true</code> if the source overlaps a given time region.
|
|
1234
|
+
*
|
|
1235
|
+
* @param {Number} startTime The start of the time region, in seconds.
|
|
1236
|
+
* @param {Number} endTime The end of the time region, in seconds.
|
|
1237
|
+
* @returns {Boolean}
|
|
1238
|
+
*
|
|
1239
|
+
* @see http://wiki.c2.com/?TestIfDateRangesOverlap
|
|
1240
|
+
*/
|
|
1241
|
+
Source.prototype.isVisible = function(startTime, endTime) {
|
|
1242
|
+
return this._startTime < endTime && startTime < this._endTime;
|
|
1243
|
+
};
|
|
1244
|
+
|
|
1245
|
+
/**
|
|
1246
|
+
* Update the indicators of this source.
|
|
1247
|
+
*
|
|
1248
|
+
* @param {Array<String>} newIndicators The new indicators.
|
|
1249
|
+
*/
|
|
1250
|
+
|
|
1251
|
+
Source.prototype.setIndicators = function(newIndicators) {
|
|
1252
|
+
this._indicators = newIndicators;
|
|
1253
|
+
this._peaks.emit('model.source.setIndicators', this);
|
|
1254
|
+
};
|
|
1255
|
+
|
|
1256
|
+
/**
|
|
1257
|
+
* Returns <code>true</code> if a warning should be shown
|
|
1258
|
+
*/
|
|
1259
|
+
|
|
1260
|
+
Source.prototype.shouldShowWarning = function() {
|
|
1261
|
+
return this._warningColor && this._duration > Utils.roundTime(this._endTime - this._startTime);
|
|
1262
|
+
};
|
|
1263
|
+
|
|
1264
|
+
Source.prototype.getVisibleTitle = function() {
|
|
1265
|
+
if (this._titleAlignments.length === 0) {
|
|
1266
|
+
return this._title;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
return this._titleAlignments.reduce(function(visibleTitle, alignment) {
|
|
1270
|
+
if (this._mediaStartTime < alignment.end && alignment.start < this._mediaEndTime) {
|
|
1271
|
+
visibleTitle.push(alignment.text);
|
|
1272
|
+
}
|
|
1273
|
+
return visibleTitle;
|
|
1274
|
+
}.bind(this), []).join(' ');
|
|
1275
|
+
};
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* Returns a serializable object containing only the properties defined with Object.defineProperties.
|
|
1279
|
+
* This includes all enumerable properties that can be safely serialized.
|
|
1280
|
+
*
|
|
1281
|
+
* @returns {Object} A plain object containing the serializable properties of the source.
|
|
1282
|
+
*/
|
|
1283
|
+
Source.prototype.toSerializable = function() {
|
|
1284
|
+
var serializable = {};
|
|
1285
|
+
|
|
1286
|
+
// Get all custom properties
|
|
1287
|
+
for (var key in this) {
|
|
1288
|
+
if (Object.prototype.hasOwnProperty.call(this, key) && key.startsWith('custom_')) {
|
|
1289
|
+
serializable[key] = this[key];
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
// Add all the enumerable properties from the prototype
|
|
1294
|
+
var proto = Object.getPrototypeOf(this);
|
|
1295
|
+
var descriptors = Object.getOwnPropertyDescriptors(proto);
|
|
1296
|
+
|
|
1297
|
+
for (var prop in descriptors) {
|
|
1298
|
+
if (Object.prototype.hasOwnProperty.call(descriptors, prop)) {
|
|
1299
|
+
var descriptor = descriptors[prop];
|
|
1300
|
+
|
|
1301
|
+
if (descriptor.enumerable && descriptor.get && typeof descriptor.get === 'function') {
|
|
1302
|
+
serializable[prop] = this[prop];
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
return serializable;
|
|
1308
|
+
};
|
|
1309
|
+
|
|
1310
|
+
return Source;
|
|
1311
|
+
});
|