src/js/widgets/sliderWidget.js
author hamidouk
Mon, 14 Nov 2011 12:16:27 +0100
branchpopcorn-port
changeset 231 accc7358d8b5
parent 226 d1f0e604bd06
child 229 808768eb5930
permissions -rw-r--r--
fixed a position bug.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
226
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
     1
IriSP.SliderWidget = function(Popcorn, config, Serializer) { 
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
     2
  IriSP.Widget.call(this, Popcorn, config, Serializer);
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
     3
};
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
     4
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
     5
IriSP.SliderWidget.prototype = new IriSP.Widget();
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
     6
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
     7
IriSP.SliderWidget.prototype.draw = function() {
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
     8
  var self = this;
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
     9
  
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    10
  this.selector.slider( { //range: "min",
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    11
    value: 0,
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    12
    min: 1,
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    13
    max: this._serializer.currentMedia().meta["dc:duration"]/1000,//1:54:52.66 = 3600+3240+
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    14
    step: 0.1,
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    15
    slide: function(event, ui) {     
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    16
      self._Popcorn.currentTime(ui.value);
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    17
    },
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    18
    /* change event is similar to slide, but it happens when the slider position is 
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    19
       modified programatically. We use it for unit tests */       
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    20
    change: function(event, ui) {      
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    21
      self._Popcorn.trigger("test.fixture", ui.value);
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    22
    }
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    23
    
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    24
  });
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    25
  
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    26
  this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.sliderUpdater));
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    27
};
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    28
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    29
/* updates the slider as time passes */
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    30
IriSP.SliderWidget.prototype.sliderUpdater = function() {  
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    31
  var currentPosition = this._Popcorn.currentTime();   
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    32
	this.selector.slider( "value", currentPosition);		
d1f0e604bd06 separated the slider from the playerWidget.
hamidouk
parents:
diff changeset
    33
};