perminder-klair / angular-soundmanager2

SoundManager2 Music Player for AngularJs
http://perminder-klair.github.io/angular-soundmanager2/
MIT License
168 stars 107 forks source link

how to use togglePause #6

Closed cawo88 closed 9 years ago

cawo88 commented 9 years ago

In Sound Manager.js there is a toggle pause function. How would you create a custom directive for this?

ghost commented 9 years ago

Hey cawo88,

You can do something like this:

$("#pause").hide();
$("#play").hide();

$("#play-all").click(function(){
        $("#play-all").hide();
        $("#pause").show();
});

$("#pause, #stop").click(function(){
        $("#pause").hide();
        $("#play").show();
});

$("#play").click(function(){
        $("#play").hide();
        $("#pause").show();
});

And put all the elements in the same position.

perminder-klair commented 9 years ago

@angelcambero thanks for your solution. But instead of using jQuery, let's stick with AngularJs.

So @cawo88 , I have created a new directive for Play Pause Toggle, here how to use it:

<button play-pause-toggle data-play="Play!" data-pause="Pause!">Play Toggle</button>

You can pass custom Play/Pause html using: data-play and data-pause.

Here is working demo: http://perminder-klair.github.io/angular-soundmanager2/