58 lines
1.2 KiB
JavaScript
58 lines
1.2 KiB
JavaScript
var player = document.getElementById('msgfmplayer');
|
|
|
|
var mp3player = {
|
|
loaded : function(){
|
|
|
|
$(".mp-play").click(function(e) {
|
|
player.play();
|
|
});
|
|
$('.mp-pause').click(function(e){
|
|
player.pause();
|
|
});
|
|
$('.mp-stop').click(function(e){
|
|
player.pause();
|
|
player.currentTime = 0;
|
|
});
|
|
$('.mp-mute').click(function(e){
|
|
|
|
});
|
|
$('.mp-volume-max').click(function(e){
|
|
|
|
});
|
|
$('.mp-restart').click(function(e) {
|
|
player.currentTime = 0;
|
|
});
|
|
|
|
player.onplay = function(e){
|
|
$('.mp-play').hide();
|
|
$('.mp-pause').show();
|
|
};
|
|
|
|
player.onpause = function(e){
|
|
$('.mp-play').show();
|
|
$('.mp-pause').hide();
|
|
};
|
|
|
|
player.onended = function(e){
|
|
mp3player.playcount($('#voice_id').val());
|
|
};
|
|
},
|
|
|
|
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(){}
|
|
});
|
|
}
|
|
}; //mp3player
|
|
|
|
$(document).ready(function(e) {
|
|
mp3player.loaded();
|
|
player.play();
|
|
}); |