Created
          December 1, 2012 06:49 
        
      - 
      
 - 
        
Save pamelafox/4180872 to your computer and use it in GitHub Desktop.  
    Detect and change playbackRate
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /** function set_speed(speed) | |
| * Set the video speed | |
| * | |
| * @param double speed - target speed | |
| * | |
| * @return void | |
| */ | |
| this.is_set_speed_enabled = function(){ | |
| if(typeof(this.mediaelement_media) === 'object' | |
| && this.mediaelement_media !== null | |
| && typeof(this.mediaelement_media.playbackRate) === 'number' | |
| && this.mediaelement_media.playbackRate > 0){ | |
| return true; | |
| } | |
| else{ | |
| return false; | |
| } | |
| } | |
| this.set_speed = function(speed) { | |
| if(this.is_set_speed_enabled()) this.mediaelement_media.playbackRate = speed; | |
| } | |
| this.get_speed = function(speed) { | |
| if(this.is_set_speed_enabled()) return this.mediaelement_media.playbackRate; | |
| else return 1; | |
| } | |
| this.increase_speed = function(deltaSpeed){ | |
| var minSpeed = 0.50; | |
| var maxSpeed = 2.00 | |
| var newSpeed = QL_player.get_speed() + deltaSpeed; | |
| if(newSpeed < minSpeed) newSpeed = minSpeed; | |
| if(newSpeed > maxSpeed) newSpeed = maxSpeed; | |
| QL_player.set_speed(newSpeed); | |
| } | |
| this.decrease_speed = function(deltaSpeed){ | |
| this.increase_speed(-deltaSpeed); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment