equal
deleted
inserted
replaced
2 The Slider Widget shows time position and allows seek |
2 The Slider Widget shows time position and allows seek |
3 */ |
3 */ |
4 |
4 |
5 IriSP.Widgets.Slice = function(player, config) { |
5 IriSP.Widgets.Slice = function(player, config) { |
6 IriSP.Widgets.Widget.call(this, player, config); |
6 IriSP.Widgets.Widget.call(this, player, config); |
|
7 this.sliding = false; |
7 }; |
8 }; |
8 |
9 |
9 IriSP.Widgets.Slice.prototype = new IriSP.Widgets.Widget(); |
10 IriSP.Widgets.Slice.prototype = new IriSP.Widgets.Widget(); |
10 |
11 |
11 IriSP.Widgets.Slice.prototype.defaults = { |
12 IriSP.Widgets.Slice.prototype.defaults = { |
12 start_visible : false, |
13 start_visible : false, |
13 pause_on_change : true, |
|
14 live_update : true |
14 live_update : true |
15 /* Shall the bounds change each time |
15 /* Shall the bounds change each time |
16 the Annotation Widget sends an update (true) |
16 the Annotation Widget sends an update (true) |
17 or only when "show" is triggered (false) ? |
17 or only when "show" is triggered (false) ? |
18 - true is to be recommended when the widget is permanently displayed. |
18 - true is to be recommended when the widget is permanently displayed. |
27 this.$.append(this.$slider); |
27 this.$.append(this.$slider); |
28 |
28 |
29 this.min = 0; |
29 this.min = 0; |
30 this.max = this.source.getDuration().valueOf(); |
30 this.max = this.source.getDuration().valueOf(); |
31 |
31 |
32 var _this = this; |
32 var _this = this, |
|
33 _currentTime; |
33 |
34 |
34 this.$slider.slider({ |
35 this.$slider.slider({ |
35 range: true, |
36 range: true, |
36 values: [0, 0], |
37 values: [0, 0], |
37 min: 0, |
38 min: 0, |
42 time:Math.floor((ui.values[0]+ui.values[1])/2) |
43 time:Math.floor((ui.values[0]+ui.values[1])/2) |
43 }); |
44 }); |
44 _this.player.popcorn.trigger("IriSP.Slice.boundsChanged",[ui.values[0], ui.values[1]]); |
45 _this.player.popcorn.trigger("IriSP.Slice.boundsChanged",[ui.values[0], ui.values[1]]); |
45 }, |
46 }, |
46 start: function() { |
47 start: function() { |
47 if (_this.pause_on_change && !_this.player.popcorn.media.paused) { |
48 _this.sliding = true; |
|
49 if (!_this.player.popcorn.media.paused) { |
48 _this.player.popcorn.pause(); |
50 _this.player.popcorn.pause(); |
49 } |
51 } |
|
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); |
50 } |
60 } |
51 }); |
61 }); |
52 this.$slider.find(".ui-slider-handle:first").addClass("Ldt-Slice-left-handle"); |
62 this.$slider.find(".ui-slider-handle:first").addClass("Ldt-Slice-left-handle"); |
53 this.$slider.find(".ui-slider-handle:last").addClass("Ldt-Slice-right-handle"); |
63 this.$slider.find(".ui-slider-handle:last").addClass("Ldt-Slice-right-handle"); |
54 if (this.start_visible) { |
64 if (this.start_visible) { |
72 this.$slider.hide(); |
82 this.$slider.hide(); |
73 this.player.popcorn.trigger("IriSP.Arrow.release"); |
83 this.player.popcorn.trigger("IriSP.Arrow.release"); |
74 } |
84 } |
75 |
85 |
76 IriSP.Widgets.Slice.prototype.storeBounds = function(_values) { |
86 IriSP.Widgets.Slice.prototype.storeBounds = function(_values) { |
77 this.min = _values[0]; |
87 if (!this.sliding && !this.player.popcorn.media.paused && (this.min != _values[0] || this.max != _values[1])) { |
78 this.max = _values[1]; |
88 this.min = _values[0]; |
79 if (this.live_update) { |
89 this.max = _values[1]; |
80 this.$slider.slider("values", [this.min, this.max]); |
90 if (this.live_update) { |
|
91 this.$slider.slider("values", [this.min, this.max]); |
|
92 } |
81 } |
93 } |
82 } |
94 } |