|
880
|
1 |
/* |
|
|
2 |
The Slider Widget shows time position and allows seek |
|
|
3 |
*/ |
|
|
4 |
|
|
|
5 |
IriSP.Widgets.Slice = function(player, config) { |
|
|
6 |
IriSP.Widgets.Widget.call(this, player, config); |
|
924
|
7 |
this.sliding = false; |
|
880
|
8 |
}; |
|
|
9 |
|
|
|
10 |
IriSP.Widgets.Slice.prototype = new IriSP.Widgets.Widget(); |
|
|
11 |
|
|
|
12 |
IriSP.Widgets.Slice.prototype.defaults = { |
|
923
|
13 |
start_visible : false, |
|
|
14 |
live_update : true |
|
|
15 |
/* Shall the bounds change each time |
|
|
16 |
the Annotation Widget sends an update (true) |
|
|
17 |
or only when "show" is triggered (false) ? |
|
|
18 |
- true is to be recommended when the widget is permanently displayed. |
|
|
19 |
*/ |
|
880
|
20 |
}; |
|
|
21 |
|
|
|
22 |
IriSP.Widgets.Slice.prototype.draw = function() { |
|
|
23 |
|
|
|
24 |
this.$slider = IriSP.jQuery('<div>') |
|
|
25 |
.addClass("Ldt-Slice") |
|
|
26 |
|
|
|
27 |
this.$.append(this.$slider); |
|
|
28 |
|
|
|
29 |
this.min = 0; |
|
904
|
30 |
this.max = this.source.getDuration().valueOf(); |
|
880
|
31 |
|
|
924
|
32 |
var _this = this, |
|
|
33 |
_currentTime; |
|
880
|
34 |
|
|
|
35 |
this.$slider.slider({ |
|
|
36 |
range: true, |
|
|
37 |
values: [0, 0], |
|
|
38 |
min: 0, |
|
|
39 |
max: this.max, |
|
|
40 |
change: function(event, ui) { |
|
|
41 |
_this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{ |
|
|
42 |
widget:_this.type, |
|
904
|
43 |
time:Math.floor((ui.values[0]+ui.values[1])/2) |
|
880
|
44 |
}); |
|
904
|
45 |
_this.player.popcorn.trigger("IriSP.Slice.boundsChanged",[ui.values[0], ui.values[1]]); |
|
923
|
46 |
}, |
|
|
47 |
start: function() { |
|
924
|
48 |
_this.sliding = true; |
|
|
49 |
if (!_this.player.popcorn.media.paused) { |
|
923
|
50 |
_this.player.popcorn.pause(); |
|
|
51 |
} |
|
924
|
52 |
_currentTime = _this.player.popcorn.currentTime(); |
|
|
53 |
}, |
|
|
54 |
slide: function(event, ui) { |
|
|
55 |
_this.player.popcorn.currentTime(ui.value / 1000); |
|
|
56 |
}, |
|
|
57 |
stop: function() { |
|
|
58 |
_this.sliding = false; |
|
|
59 |
_this.player.popcorn.currentTime(_currentTime); |
|
880
|
60 |
} |
|
|
61 |
}); |
|
|
62 |
this.$slider.find(".ui-slider-handle:first").addClass("Ldt-Slice-left-handle"); |
|
|
63 |
this.$slider.find(".ui-slider-handle:last").addClass("Ldt-Slice-right-handle"); |
|
|
64 |
if (this.start_visible) { |
|
|
65 |
this.show(); |
|
|
66 |
} else { |
|
|
67 |
this.hide(); |
|
|
68 |
} |
|
|
69 |
this.bindPopcorn("IriSP.Slice.show","show"); |
|
|
70 |
this.bindPopcorn("IriSP.Slice.hide","hide"); |
|
904
|
71 |
this.bindPopcorn("IriSP.Annotation.boundsChanged","storeBounds"); |
|
923
|
72 |
this.trigger("IriSP.Annotation.getBounds"); |
|
880
|
73 |
}; |
|
|
74 |
|
|
|
75 |
IriSP.Widgets.Slice.prototype.show = function() { |
|
|
76 |
this.$slider.show(); |
|
|
77 |
this.player.popcorn.trigger("IriSP.Arrow.takeover",this.type); |
|
|
78 |
this.$slider.slider("values", [this.min, this.max]); |
|
|
79 |
} |
|
|
80 |
|
|
|
81 |
IriSP.Widgets.Slice.prototype.hide = function() { |
|
|
82 |
this.$slider.hide(); |
|
|
83 |
this.player.popcorn.trigger("IriSP.Arrow.release"); |
|
|
84 |
} |
|
|
85 |
|
|
|
86 |
IriSP.Widgets.Slice.prototype.storeBounds = function(_values) { |
|
924
|
87 |
if (!this.sliding && !this.player.popcorn.media.paused && (this.min != _values[0] || this.max != _values[1])) { |
|
|
88 |
this.min = _values[0]; |
|
|
89 |
this.max = _values[1]; |
|
|
90 |
if (this.live_update) { |
|
|
91 |
this.$slider.slider("values", [this.min, this.max]); |
|
|
92 |
} |
|
923
|
93 |
} |
|
880
|
94 |
} |