|
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 = { |
|
1020
|
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 |
*/ |
|
|
20 |
override_bounds : true |
|
|
21 |
/* Can the Annotation Widget bounds be overriden ? */ |
|
880
|
22 |
}; |
|
|
23 |
|
|
|
24 |
IriSP.Widgets.Slice.prototype.draw = function() { |
|
|
25 |
|
|
1020
|
26 |
this.$slider = IriSP.jQuery('<div>') |
|
|
27 |
.addClass("Ldt-Slice") |
|
880
|
28 |
|
|
1020
|
29 |
this.$.append(this.$slider); |
|
880
|
30 |
|
|
|
31 |
this.min = 0; |
|
1020
|
32 |
this.max = this.source.getDuration().valueOf(); |
|
880
|
33 |
|
|
924
|
34 |
var _this = this, |
|
|
35 |
_currentTime; |
|
880
|
36 |
|
|
|
37 |
this.$slider.slider({ |
|
|
38 |
range: true, |
|
1020
|
39 |
values: [0, 0], |
|
880
|
40 |
min: 0, |
|
|
41 |
max: this.max, |
|
|
42 |
change: function(event, ui) { |
|
1020
|
43 |
_this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{ |
|
|
44 |
widget:_this.type, |
|
|
45 |
time:Math.floor((ui.values[0]+ui.values[1])/2) |
|
|
46 |
}); |
|
|
47 |
_this.player.popcorn.trigger("IriSP.Slice.boundsChanged",[ui.values[0], ui.values[1]]); |
|
923
|
48 |
}, |
|
|
49 |
start: function() { |
|
924
|
50 |
_this.sliding = true; |
|
1020
|
51 |
if (!_this.player.popcorn.media.paused) { |
|
|
52 |
_this.player.popcorn.pause(); |
|
923
|
53 |
} |
|
1020
|
54 |
_currentTime = _this.player.popcorn.currentTime(); |
|
924
|
55 |
}, |
|
|
56 |
slide: function(event, ui) { |
|
1020
|
57 |
if (!_this.override_bounds && (ui.value < _this.min || ui.value > _this.max)) { |
|
|
58 |
return false; |
|
|
59 |
} |
|
|
60 |
_this.player.popcorn.currentTime(ui.value / 1000); |
|
924
|
61 |
}, |
|
|
62 |
stop: function() { |
|
|
63 |
_this.sliding = false; |
|
1020
|
64 |
_this.player.popcorn.currentTime(_currentTime); |
|
880
|
65 |
} |
|
|
66 |
}); |
|
|
67 |
this.$slider.find(".ui-slider-handle:first").addClass("Ldt-Slice-left-handle"); |
|
|
68 |
this.$slider.find(".ui-slider-handle:last").addClass("Ldt-Slice-right-handle"); |
|
1020
|
69 |
if (this.start_visible) { |
|
|
70 |
this.show(); |
|
|
71 |
} else { |
|
|
72 |
this.hide(); |
|
|
73 |
} |
|
|
74 |
this.bindPopcorn("IriSP.Slice.show","show"); |
|
|
75 |
this.bindPopcorn("IriSP.Slice.hide","hide"); |
|
|
76 |
this.bindPopcorn("IriSP.Annotation.boundsChanged","storeBounds"); |
|
|
77 |
this.player.popcorn.trigger("IriSP.Annotation.getBounds"); |
|
880
|
78 |
}; |
|
|
79 |
|
|
|
80 |
IriSP.Widgets.Slice.prototype.show = function() { |
|
|
81 |
this.$slider.show(); |
|
1020
|
82 |
this.player.popcorn.trigger("IriSP.Arrow.takeover",this.type); |
|
|
83 |
this.$slider.slider("values", [this.min, this.max]); |
|
|
84 |
} |
|
880
|
85 |
|
|
|
86 |
IriSP.Widgets.Slice.prototype.hide = function() { |
|
|
87 |
this.$slider.hide(); |
|
1020
|
88 |
this.player.popcorn.trigger("IriSP.Arrow.release"); |
|
|
89 |
} |
|
|
90 |
|
|
|
91 |
IriSP.Widgets.Slice.prototype.storeBounds = function(_values) { |
|
|
92 |
if (!this.player.popcorn.media.paused && (this.min != _values[0] || this.max != _values[1])) { |
|
|
93 |
this.min = _values[0]; |
|
|
94 |
this.max = _values[1]; |
|
|
95 |
if (this.live_update && !this.sliding) { |
|
|
96 |
this.$slider.slider("values", [this.min, this.max]); |
|
|
97 |
} |
|
|
98 |
} |
|
|
99 |
} |