1

I'm using bigvideo.js and want to use a div that when clicked pause or play the player.

How can I toggle that on first click it pauses, then if click again played and so on...

jQuery('#bigvideo-pause').on('click', function() {
    BV.getPlayer().pause();
    BV.getPlayer().play();
});
Pranav C Balan
  • 113,687
  • 23
  • 165
  • 188
codek
  • 343
  • 4
  • 20
  • 49

1 Answers1

3

Use a boolean variable to toggle

jQuery('#bigvideo-pause').on('click', function() {
    BV.getPlayer()[this.play ? 'pause' : 'play']();
    this.play = !this.play;
});
Pranav C Balan
  • 113,687
  • 23
  • 165
  • 188
  • 1
    I've upvoted, but I'd be tempted to set a property on the node, rather than using a global variable, and rearrange a little: `BV.getPlayer()[this.play ? 'pause' : 'play'](); this.play = !this.play;` (Your approach is far more readable, though). – David Thomas Oct 11 '14 at 13:20
  • Yup , can I add it to my answer – Pranav C Balan Oct 11 '14 at 13:21