1

I am using the Jplayer query plugin as an audio player on mysite. While I manage to set the options of the plugin through this:

$(document).ready(function(){

$("#jquery_jplayer_1").jPlayer({
    ready: function () {
        $(this).jPlayer("setMedia", {
            title: MediaTitle,
            mp3: MediaURL
        });
    },
    remainingDuration: true,
    defaultPlaybackRate: 1,  /* <-- I'd like to change the playback rate 
                                    when I click a button */
    toggleDuration: true
});
});

my goal is to assign a button to control the playback rate so when for example I press "speed" button the deafultPlaybackRate would go from 1 to 1.5 for example.

I'm thinking approaching this is by using the .click mouse event.

For example:

   <script type="text/javascript">
   $( ".speeder" ).click(function() {
       /*make the defaultPlaybackRate go from 1 to 1.5 */
    });
   </script> 

Am I on the right path? is it even possible to change global jquery plugin settings through events like a mouse click on a button?

vinayakj
  • 5,179
  • 3
  • 25
  • 45
FLVR
  • 39
  • 7
  • `$("#jquery_jplayer_1").jPlayer("options",{defaultPlaybackRate : 1.5});` If plugin follows jQuery plugins code standards – vinayakj Jul 26 '15 at 09:26
  • 1
    possible duplicate of [How to change the playing speed of videos in HTML5?](http://stackoverflow.com/questions/3027707/how-to-change-the-playing-speed-of-videos-in-html5) – lshettyl Jul 26 '15 at 09:27

1 Answers1

1

Check out the documentation here:

<script type="text/javascript">
   $( ".speeder" ).click(function() {
       $("#jquery_jplayer_1").jPlayer("option","playbackRate", "1.5"); // or
       //$("#jquery_jplayer_1").jPlayer("option",{playbackRate : 1.5});
    });
</script> 
vinayakj
  • 5,179
  • 3
  • 25
  • 45
  • this code seems about right but it doesn't work for me unfortunately :( Thank you for your answer though – FLVR Jul 26 '15 at 11:45
  • @vinayaki http://jsfiddle.net/FLVR/XLNCY/18402/ Hopefully this is understandable... I am trying to assign to assign the speed buttons (.button1, .button125, .button15) to control the defaultPlaybackRate parameter accordingly – FLVR Jul 26 '15 at 15:17
  • Well code is running correctly, you can check the log. http://jsfiddle.net/pxocLg68/ – vinayakj Jul 26 '15 at 15:32
  • according to the log it running fine but unfortunately the actual speed of the track isn't changing – FLVR Jul 26 '15 at 20:21
  • Thats `defaultPlaybackRate` its there when you dont change, I think you need to revisit API docs to find right method to change playback rate maybe `$("#jquery_jplayer_1").jPlayer("option","playbackRate", "1.5");` – vinayakj Jul 26 '15 at 20:23