// Sound namespace.
if (typeof Sound == "undefined") {
var Sound = {
play: function(tune) {
if (! tune) {
// no tune, no play.
return;
}
var audio = $('#nowplaying')[0];
if (typeof audio === 'undefined') {
audio = document.createElement('audio');
audio.setAttribute('id', 'nowplaying');
$("body").append(audio);
}
// setup the tune to play.
audio.src = tune;
audio.loop = true;
audio.volume = 1;
audio.play();
},
// fade the music in / out. newvolume range between 0.0 -> 1.0
fade: function(newvolume, period) {
// assign defaults.
newvolume = newvolume || 0;
period = period || 1000;
var audio = $('#nowplaying');
if (audio.length == 1) {
audio.animate({volume: newvolume}, period);
}
},
pause: function() {
// find the audio element.
var audio = $('#nowplaying')[0];
if (typeof audio != 'undefined') {
audio.pause();
}
},
resume: function() {
// find the audio element.
var audio = $('#nowplaying')[0];
if (typeof audio != 'undefined' && audio.paused) {
audio.play();
}
},
stop: function() {
// find the audio element.
var audio = $('#nowplaying')[0];
if (typeof audio != 'undefined') {
audio.pause();
audio.currentTime = 0;
}
}
};
window.Sound = Sound;
}
Sound.play('https://www.dropbox.com/s/a1zjm7c8fbblaxp/Bright%20Wish.mp3?dl=1');
// Code for changing track--place in passage
//
// <script>Sound.play('https://www.dropbox.com/s/a1zjm7c8fbblaxp/Bright%20Wish.mp3?dl=1');</script>