src/js/widgets/sliderWidget.js
branchpopcorn-port
changeset 226 d1f0e604bd06
child 229 808768eb5930
equal deleted inserted replaced
225:53a712511a08 226:d1f0e604bd06
       
     1 IriSP.SliderWidget = function(Popcorn, config, Serializer) { 
       
     2   IriSP.Widget.call(this, Popcorn, config, Serializer);
       
     3 };
       
     4 
       
     5 IriSP.SliderWidget.prototype = new IriSP.Widget();
       
     6 
       
     7 IriSP.SliderWidget.prototype.draw = function() {
       
     8   var self = this;
       
     9   
       
    10   this.selector.slider( { //range: "min",
       
    11     value: 0,
       
    12     min: 1,
       
    13     max: this._serializer.currentMedia().meta["dc:duration"]/1000,//1:54:52.66 = 3600+3240+
       
    14     step: 0.1,
       
    15     slide: function(event, ui) {     
       
    16       self._Popcorn.currentTime(ui.value);
       
    17     },
       
    18     /* change event is similar to slide, but it happens when the slider position is 
       
    19        modified programatically. We use it for unit tests */       
       
    20     change: function(event, ui) {      
       
    21       self._Popcorn.trigger("test.fixture", ui.value);
       
    22     }
       
    23     
       
    24   });
       
    25   
       
    26   this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.sliderUpdater));
       
    27 };
       
    28 
       
    29 /* updates the slider as time passes */
       
    30 IriSP.SliderWidget.prototype.sliderUpdater = function() {  
       
    31   var currentPosition = this._Popcorn.currentTime();   
       
    32 	this.selector.slider( "value", currentPosition);		
       
    33 };