127 lines
3.2 KiB
JavaScript
127 lines
3.2 KiB
JavaScript
var msgfmplayer;
|
|
|
|
var track = {
|
|
id : _this.vid,
|
|
mp3 : null,
|
|
ctl : null,
|
|
ctl_play : null,
|
|
ctl_pause : null,
|
|
ctl_stop : null,
|
|
ctl_mute : null,
|
|
ctl_volume_max : null,
|
|
ctl_volume_bar : null,
|
|
ctl_playstatus : null,
|
|
playtime : 0
|
|
};
|
|
|
|
var mp3player = {
|
|
loaded : function(){
|
|
|
|
msgfmplayer = $("#jquery_jplayer");
|
|
|
|
$.jPlayer.timeFormat.padMin = false;
|
|
$.jPlayer.timeFormat.padSec = false;
|
|
$.jPlayer.timeFormat.sepMin = ":";
|
|
$.jPlayer.timeFormat.sepSec = "";
|
|
|
|
msgfmplayer.jPlayer({
|
|
swfPath: "/static/lib/jplayer",
|
|
supplied: "mp3",
|
|
solution:"flash,html",
|
|
ended: function(event){
|
|
mp3player.paused();
|
|
mp3player.playcount(track.id);
|
|
},
|
|
timeupdate: function(event) {
|
|
slider.slider( "value", parseInt(event.jPlayer.status.currentPercentRelative, 10) );
|
|
|
|
//$('#play-status').text(parseInt(event.jPlayer.status.currentPercentRelative, 10) + "%");
|
|
//$('#play-status').text(event.jPlayer.status.currentTime);
|
|
track.ctl_playstatus.text(event.jPlayer.status.seekPercent);
|
|
},
|
|
ready : function(){
|
|
if(_this.autoplay)
|
|
{
|
|
$(".jp-play").click();
|
|
}
|
|
}
|
|
});
|
|
|
|
$(".jp-play").click(function(e) {
|
|
if($(this).prev('input[name=track]').val() != track.mp3)
|
|
{
|
|
track.ctl = $('#msgfmplayer-ctl');
|
|
track.mp3 = track.ctl.children('input[name=track]').val();
|
|
msgfmplayer.jPlayer("setMedia", {
|
|
mp3: track.mp3,
|
|
});
|
|
track.ctl_play = track.ctl.children('.jp-play');
|
|
track.ctl_pause = track.ctl.children('.jp-pause');
|
|
track.ctl_stop = track.ctl.children('.jp-stop');
|
|
track.ctl_mute = track.ctl.children('.jp-mute');
|
|
track.ctl_volume_max = track.ctl.children('.jp-volume-max');
|
|
track.ctl_volume_bar = $('#volume-ctl');
|
|
track.ctl_playstatus = $('#play-status');
|
|
}
|
|
msgfmplayer.jPlayer("play");
|
|
track.ctl_play.hide();
|
|
track.ctl_pause.show();
|
|
track.ctl_volume_bar.show();
|
|
track.ctl_playstatus.show();
|
|
$(this).blur();
|
|
});
|
|
$('.jp-pause').click(function(e){
|
|
msgfmplayer.jPlayer("pause");
|
|
mp3player.paused();
|
|
});
|
|
$('.jp-stop').click(function(e){
|
|
mp3player.paused();
|
|
msgfmplayer.jPlayer("stop");
|
|
mp3player.playcount(track.id);
|
|
});
|
|
$('.jp-mute').click(function(e){
|
|
msgfmplayer.jPlayer("mute");
|
|
track.ctl_mute.hide();
|
|
track.ctl_volume_max.show();
|
|
});
|
|
$('.jp-volume-max').click(function(e){
|
|
msgfmplayer.jPlayer("unmute");
|
|
track.ctl_volume_max.hide();
|
|
track.ctl_mute.show();
|
|
});
|
|
},
|
|
paused : function(){
|
|
track.ctl_play.show();
|
|
track.ctl_pause.hide();
|
|
track.ctl_volume_bar.hide();
|
|
track.ctl_playstatus.hide();
|
|
},
|
|
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();
|
|
|
|
$( "#volume-ctl" ).slider({
|
|
range: "min",
|
|
min: 0,
|
|
max: 100,
|
|
step: 10,
|
|
value: 60,
|
|
slide: function( event, ui ) {
|
|
msgfmplayer.jPlayer("volume", ui.value / 100);
|
|
}
|
|
});
|
|
|
|
}); |