jquery - ttwMusicPlayer action on play button -


i'm using ttwmusicplayer on site. it's usage pretty simple.

<div id='mainplayer'></div> 

in html , in js

$('#mainplayer').ttwmusicplayer(myplaylist, {                 autoplay:false,                  description:description,                 jplayer:{                     swfpath:'path jplayer.swf is' //you need override default swf path time directory structure changes                 }             });  

it's easy, have looking player. want add action on it's play-button. (i want make ability play server , soundcloud). here code of div play button of player:

<div class="play jp-play" style="display: block;"></div> 

so after $(document).ready() of course

.on('click','.jp-play',function(){     alert("works"); }); 

and after click on play button music plays there no alert. how can override it's default action?

here's how can it:

$(document).on($.jplayer.event.play, function(e){     console.log("play!");     alert("works"); }); 

this uses jplayer event play.

other supported event types described here: http://jplayer.org/latest/developer-guide/#jplayer-event-type

full example: jsfiddle


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -