Hello, it's me again. Sorry that I have so many questions. I'm new to this. I'm using
Harlowe.
I have my story set up to play eight different sounds. I have them all set to loop in my Story Javascript, but they're all supposed to be paused or silent in the starting passage. I then fade them in and out as I need them to. All but one sound has worked as it should. Every time I play my story, this one song starts playing, even though I have it set to be quiet just like the rest. It's only this one sound. Here's what my Story Javascript looks like. It's a mess, I know.
var audio = document.createElement('audio');
audio.setAttribute('id', 'nowplayingbirds');
audio.src = 'music/birds.mp3';
audio.loop = true;
$("body").append(audio);
audio.play();
var audio = document.createElement('audio');
audio.setAttribute('id', 'nowplayinglaughing');
audio.src = 'music/laughing.mp3';
audio.loop = true;
$("body").append(audio);
audio.play();
var audio = document.createElement('audio');
audio.setAttribute('id', 'nowplayingdripping');
audio.src = 'music/water_drops.mp3';
audio.loop = true;
$("body").append(audio);
audio.play();
var audio = document.createElement('audio');
audio.setAttribute('id', 'nowplayingviolin');
audio.src = 'music/SadViolin.mp3';
audio.loop = true;
$("body").append(audio);
audio.play();
var audio = document.createElement('audio');
audio.setAttribute('id', 'nowplayingcrying');
audio.src = 'music/crying.mp3';
audio.loop = true;
$("body").append(audio);
audio.play();
var audio = document.createElement('audio');
audio.setAttribute('id', 'nowplayingnight');
audio.src = 'music/night.mp3';
audio.loop = true;
$("body").append(audio);
audio.play();
var audio = document.createElement('audio');
audio.setAttribute('id', 'nowplayingdarkness');
audio.src = 'music/darkness.mp3';
audio.loop = true;
$("body").append(audio);
audio.play();
var audio = document.createElement('audio');
audio.setAttribute('id', 'nowplayingpiano');
audio.src = 'music/piano.mp3';
audio.loop = true;
$("body").append(audio);
audio.play();
And I have a passage set up with the tag, stylesheet, with the following inside. This passage tells the sounds to stay quiet until I give them the command.
<div style="display: none;"><img src="!@#$" onerror="$('#nowplayingbirds').animate({volume: 0}, 0);" /></div>
<div style="display: none;"><img src="!@#$" onerror="$('#nowplayinglaughing').animate({volume: 0}, 0);"/></div>
<div style="display: none;"><img src="!@#$" onerror="$('#nowplayingdripping').animate({volume: 0}, 0);" /></div>
<div style="display: none;"><img src="!@#$" onerror="$('#nowplayingviolin').animate({volume: 0}, 0);" /></div>
<div style="display: none;"><img src="!@#$" onerror="$('#nowplayingcrying').animate({volume: 0}, 0);" /></div>
<div style="display: none;"><img src="!@#$" onerror="$('#nowplayingnight').animate({volume: 0}, 0);" /></div>
<div style="display: none;"><img src="!@#$" onerror="$('#nowplayingdarkness').animate({volume: 0}, 0);"/></div>
<div style="display: none;"><img src="!@#$" onerror="$('#nowplayingpiano').animate({volume: 0}, 0);" /></div>
It's piano in particular that keeps playing even though I tell it not to.
I know there are probably easier, cleaner ways of accomplishing this. Thank you in advance!
Comments
To test if this is the case, if you swap the order of "darkness.mp3" and "piano.mp3" in your JavaScript, does "darkness.mp3" now play nonstop?
To fix it (and yes, haha, there are better ways, I'm sure!) if instead of... ...you write... ...then I think you might get the effect you're looking for, where it plays the audio, just silently, and when the audio volume is triggered, the browser doesn't start that music at the beginning of the MP3, but rather, at the point it would be were it playing all along. Is that right? If I'm misunderstanding whether or not that's the effect you want, let me know! One of those "easier, cleaner ways" you mentioned might be a good solution.