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();
});
0

1 Answer 1

3

Use a boolean variable to toggle

jQuery('#bigvideo-pause').on('click', function() {
    BV.getPlayer()[this.play ? 'pause' : 'play']();
    this.play = !this.play;
});
Sign up to request clarification or add additional context in comments.

2 Comments

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).
Yup , can I add it to my answer

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.