var player; var id = $('#msgfmplayer-ctl input[name=trackid]').val(); var track = $('#msgfmplayer-ctl input[name=track]').val(); var mp3player = { loaded : function(){ player = document.getElementById('jquery_jplayer'); $(".jp-play").click(function(e) { player.play(); }); $('.jp-pause').click(function(e){ player.pause(); }); $('.jp-stop').click(function(e){ player.pause(); player.currentTime = 0; }); $('.jp-mute').click(function(e){ player.volume = 0; $( "#volume-ctl" ).slider("value",0); }); $('.jp-volume-max').click(function(e){ player.volume = 1; $( "#volume-ctl" ).slider("value",100); }); $( "#volume-ctl" ).slider({ range: "min", min: 0, max: 100, step: 10, value: 60, slide: function( event, ui ) { player.volume = ui.value / 100; } }); player.onplay = function(e){ $('.jp-play').hide(); $('.jp-pause').show(); $('#volume-ctl').show(); $('#play-status').show(); }; player.onpause = function(e){ $('.jp-play').show(); $('.jp-pause').hide(); $('#volume-ctl').hide(); $('#play-status').hide(); }; player.onended = function(e){ mp3player.playcount(id); $('#play-status').hide(); }; player.onvolumechange = function(e){ if(player.volume == 0) { $('.jp-volume-max').show(); $('.jp-mute').hide(); }else{ $('.jp-volume-max').hide(); $('.jp-mute').show(); } }; player.ontimeupdate = function(e){ $("#progressbar").slider("value",Math.round((player.currentTime / player.duration) * 100)); $('#timer_current').html(formatSeconds(player.currentTime)); }; player.ondurationchange = function(e){ $('#timer_duration').html(formatSeconds(player.duration)); }; }, playcount : function(id){ $.ajax({ type:"POST", url:"/voice/count/" + id, data:"", success:function(data){$("#play_count").html( parseInt($('#play_count').html()) + 1 )}, timeout: 5000, error: function(){}, beforeSend: function(){}, complete: function(){} }); }, appendplayer : function(){ $('#html5player').html(''); }, appendtimer : function(){ $('#html5player').after('