Forum Discussion
// get storyline player
var player, audiofolder, audiofile;
player = GetPlayer();
window.audiotrack = document.getElementById('ambient-music');
//
if (window.audiotrack === null) {
audiofolder = player.GetVar('audiofolder');
audiofile = player.GetVar('audiofile');
window.audiotrack = document.createElement('audio');
window.audiotrack.id = 'ambient-music';
window.audiotrack.controls = false;
window.audiotrack.loop = true;
window.audiotrack.src = 'story_content/WebObjects/' + audiofolder + '/'+audiofile;
window.audiotrack.type = 'audio/mpeg';
window.audiotrack.preload = 'auto';
// append to body
document.getElementsByTagName('body')[0].appendChild(window.audiotrack);
}
// determine if audio is playing
// show the big play button
if (window.audiotrack.paused) {
window.audiotrack.play().then(response => {}).catch(e => {
player.SetVar('showbtnplay', true);
console.log('Couldn\'t play the music becuase....', e);
});
}
Hi Sandra,
I cannot confess to being a wiz with javascript, but noting that you appear to have your music track variable set to audiofile, could you use:
audiofile.volume = xx
where xx is equal to the percentage of full volume that you want (i.e. 1 = 100%, 0.5 = 50% etc).
My gut feeling is that this would only affect your music track and not your voiceover, but I may be wrong.