function audioPlayerButtons() {
$player_back = $('#player-back');
$player_next = $('#player-next');
$player_random = $('#player-random');
$player_pause = $('#player-pause');
$player_play = $('#player-play');
$player_volume = $('#player-volume');
$audio.on('ended', function () {
track_index += 1;
setTrack();
});
$player_back.click(function (e) {
if ((track_index - 1) < 0) {
track_index = audioPlayerList.length - 1;
setTrack();
$audio.trigger('play');
return;
}
track_index -= 1;
setTrack();
});
$player_next.click(function (e) {
if ((track_index + 1) > audioPlayerList.length) {
track_index = 0;
setTrack();
$audio.trigger('play');
return;
}
track_index += 1;
setTrack();
});
$player_pause.click(function (e) {
$audio.trigger('pause');
});
$player_play.click(function (e) {
$audio.trigger('play');
});
$player_volume.change(function (e) {
$audio.volume = $player_volume.val() / 100;
console.log($audio.volume);
});
}
function setTrack() {
first_audio_track = audioPlayerList[0];
track_index = 0;
$audio.attr('src', audio_path + first_audio_track.file);
$current_track_name_ui.text(first_audio_track.filename);
if (first_audio_track.youtube) {
$current_track_link_ui.show();
$current_track_link_ui.attr('href', first_audio_track.youtube);
} else {
$current_track_link_ui.hide();
}
}
function initializeAudioPlayer() {
audio_path = '/storage/tracks/kimberannie/';
$audio = $('#audio');
$current_track_name_ui = $('.kimberly-radio .track .running p');
$current_track_link_ui = $('.kimberly-radio .track .running a');
if (audioPlayerList.length === 0) return;
audioPlayerButtons();
setTrack();
// $audio.trigger('play');
}
initializeAudioPlayer();
function audioPlayerButtons() {
$player_back = $('#player-back');
$player_next = $('#player-next');
$player_random = $('#player-random');
$player_pause = $('#player-pause');
$player_play = $('#player-play');
$player_volume = $('#player-volume');
audio.addEventListener('onended', function () {
track_index += 1;
setTrack();
});
$player_back.click(function (e) {
if ((track_index - 1) < 0) {
track_index = audioPlayerList.length - 1;
setTrack();
audio.play();
return;
}
track_index -= 1;
setTrack();
});
$player_next.click(function (e) {
if ((track_index + 1) > audioPlayerList.length) {
track_index = 0;
setTrack();
audio.play();
return;
}
track_index += 1;
setTrack();
});
$player_pause.click(function (e) {
audio.pause();
});
$player_play.click(function (e) {
audio.play();
});
$player_volume.change(function (e) {
audio.volume = $player_volume.val() / 100;
});
}
function setTrack() {
first_audio_track = audioPlayerList[0];
track_index = 0;
audio.src = audio_path + first_audio_track.file;
$current_track_name_ui.text(first_audio_track.filename);
if (first_audio_track.youtube) {
$current_track_link_ui.show();
$current_track_link_ui.attr('href', first_audio_track.youtube);
} else {
$current_track_link_ui.hide();
}
}
function initializeAudioPlayer() {
audio_path = '/storage/tracks/kimberannie/';
audio = new Audio();
$current_track_name_ui = $('.kimberly-radio .track .running p');
$current_track_link_ui = $('.kimberly-radio .track .running a');
if (audioPlayerList.length === 0) return;
audioPlayerButtons();
setTrack();
}
initializeAudioPlayer();