src/widgets/Slice.js
branchplayers-as-widgets
changeset 957 4da0a5740b6c
parent 928 5aadbc9f27cd
child 965 eadb7290c325
equal deleted inserted replaced
956:7c1d08cf6956 957:4da0a5740b6c
    38         range: true,
    38         range: true,
    39         values: [0, 0],
    39         values: [0, 0],
    40         min: 0,
    40         min: 0,
    41         max: this.max,
    41         max: this.max,
    42         change: function(event, ui) {
    42         change: function(event, ui) {
    43             _this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{
    43             _this.player.trigger("Arrow.updatePosition",{
    44                 widget:_this.type,
    44                 widget:_this.type,
    45                 time:Math.floor((ui.values[0]+ui.values[1])/2)
    45                 time:Math.floor((ui.values[0]+ui.values[1])/2)
    46             });
    46             });
    47             _this.player.popcorn.trigger("IriSP.Slice.boundsChanged",[ui.values[0], ui.values[1]]);
    47             _this.player.trigger("Slice.boundsChanged",[ui.values[0], ui.values[1]]);
    48         },
    48         },
    49         start: function() {
    49         start: function() {
    50             _this.sliding = true;
    50             _this.sliding = true;
    51             if (!_this.player.popcorn.media.paused) {
    51             if (!_this.media.getPaused) {
    52                 _this.player.popcorn.pause();
    52                 _this.media.pause();
    53             }
    53             }
    54             _currentTime = _this.player.popcorn.currentTime();
    54             _currentTime = _this.media.getCurrentTime();
    55         },
    55         },
    56         slide: function(event, ui) {
    56         slide: function(event, ui) {
    57             if (!_this.override_bounds && (ui.value < _this.min || ui.value > _this.max)) {
    57             if (!_this.override_bounds && (ui.value < _this.min || ui.value > _this.max)) {
    58                 return false;
    58                 return false;
    59             }
    59             }
    60             _this.player.popcorn.currentTime(ui.value / 1000);
    60             _this.media.setCurrentTime(ui.value);
    61         },
    61         },
    62         stop: function() {
    62         stop: function() {
    63             _this.sliding = false;
    63             _this.sliding = false;
    64             _this.player.popcorn.currentTime(_currentTime);
    64             _this.media.setCurrentTime(_currentTime);
    65         }
    65         }
    66     });
    66     });
    67     this.$slider.find(".ui-slider-handle:first").addClass("Ldt-Slice-left-handle");
    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");
    68     this.$slider.find(".ui-slider-handle:last").addClass("Ldt-Slice-right-handle");
    69     if (this.start_visible) {
    69     if (this.start_visible) {
    70         this.show();
    70         this.show();
    71     } else {
    71     } else {
    72         this.hide();
    72         this.hide();
    73     }
    73     }
    74     this.bindPopcorn("IriSP.Slice.show","show");
    74     this.onMdpEvent("Slice.show","show");
    75     this.bindPopcorn("IriSP.Slice.hide","hide");
    75     this.onMdpEvent("Slice.hide","hide");
    76     this.bindPopcorn("IriSP.Annotation.boundsChanged","storeBounds");
    76     this.onMdpEvent("Annotation.boundsChanged","storeBounds");
    77     this.player.popcorn.trigger("IriSP.Annotation.getBounds");
    77     this.player.trigger("Annotation.getBounds");
    78 };
    78 };
    79 
    79 
    80 IriSP.Widgets.Slice.prototype.show = function() {
    80 IriSP.Widgets.Slice.prototype.show = function() {
    81     this.$slider.show();
    81     this.$slider.show();
    82     this.player.popcorn.trigger("IriSP.Arrow.takeover",this.type);
    82     this.player.trigger("Arrow.takeover",this.type);
    83     this.$slider.slider("values", [this.min, this.max]);
    83     this.$slider.slider("values", [this.min, this.max]);
    84 }
    84 }
    85 
    85 
    86 IriSP.Widgets.Slice.prototype.hide = function() {
    86 IriSP.Widgets.Slice.prototype.hide = function() {
    87     this.$slider.hide();
    87     this.$slider.hide();
    88     this.player.popcorn.trigger("IriSP.Arrow.release");
    88     this.player.trigger("Arrow.release");
    89 }
    89 }
    90 
    90 
    91 IriSP.Widgets.Slice.prototype.storeBounds = function(_values) {
    91 IriSP.Widgets.Slice.prototype.storeBounds = function(_values) {
    92     if (!this.player.popcorn.media.paused && (this.min != _values[0] || this.max != _values[1])) {
    92     if (!this.media.getPaused() && (this.min != _values[0] || this.max != _values[1])) {
    93         this.min = _values[0];
    93         this.min = _values[0];
    94         this.max = _values[1];
    94         this.max = _values[1];
    95         if (this.live_update && !this.sliding) {
    95         if (this.live_update && !this.sliding) {
    96             this.$slider.slider("values", [this.min, this.max]);
    96             this.$slider.slider("values", [this.min, this.max]);
    97         }
    97         }