For ex. If v_Choice = 1, then play "audioX.mp3".
In that page you could set up a variable change listener and cycle through the audio files.
I have an example somewhere, I'll see if I can find it and post the code tomorrow.
What action sets the variable?
This code will play an audio file based on the value of v_Choice.
The audio files are in a folder named "_audio" and the audio file names are audio1.mp3, audio2.mp3, etc.
Zip the html file and the _audio folder together and insert as an html5 animation.
var wp = window.parent;
var aud = null;
aud = document.getElementById( 'myAudio' );
wp.cpAPIEventEmitter.addEventListener( 'CPAPI_VARIABLEVALUECHANGED', function ()
playAudio( wp.window.v_Choice ); }, 'v_Choice'
function playAudio( which )
aud.src = '_audio/audio'+ which +'.mp3';
<audio id='myAudio' src='' preload='none'></audio>
Great! I appreciate the follow-up. I'll try it out today.
I'm just following up to say that the html animation works brilliantly. Thanks again!
Could you mark the answer as correct.
Done, David, I used my 'magical' moderator power
Thanks Lilybiri.Thought I'd done that. I'm sure others will make good use of the answer,
Hi, this solution directly addersses a challenge I have and I want to try it. But my meager js work has all been within Captivate and I'm not sure how/where to integrate code in published files. Can you point me to a good resource for that?
I'd like to pop such code into source windows within cP, with the understanding that to audio files would still need to reside in the ar folder of the publisched ouput.
I've tried testing versions of the code myself but an not geting results.
Any guidance would be most appreciated.
The real problem is that Captivate renames the audio files that you bring into the library to some random number (or maybe not so random - not sure) for some reason that is unknown to me.
Now - I realize this is not the real answer to your question but if you have a small number of audio files, it might be worth the time.
1. Go ahead and upload your audio file to the library. Let's say it is named test.mp3
2. Publish your project to the computer and then look in the ar folder
3. Perhaps you'll find a file in there called 5472.mp3
4. Delete your published folder
6. This would be the code to make that audio file play. cp.playAudio("5472");
I wish it were as simple as making a button that said cp.playAudio("test"); and simply dropping the file in the folder after the fact but it doesn't work.
So again, if you have a small number of audio files you can upload them to your library and then publish and go see how each of the files have been renamed and then you can use the real short line of code to pull it off. The renamed file does not seem to get renamed after the first time.
Hopefully this is helpful in some way and maybe even works out for you.
It won't work unless the audio files have a sequence, which as Stagprime said, they are random. You could have the script get the audio files in the project, but it wouldn't know which ones to use. The only way that audio gets put in the ar folder is if it's being used in the project, not just in the library.
Thanks for the idea, Stegman, but I agree with David that I should try the solution he already provided. I never used HTML5 Animation before, though. I understand zipping the HTML5 document and _audio folder together, but am not clear how to insert that file into Captivate. It seems that I need to use the Captivate Package feature for that. Is that right?
Do I actually have to publish something from HTML5 Animate, or do I simply insert the zipped file, as you've descibed, into Captivate as an HTML5 Animate object?
Just want to be sure I'm testing this properly.
That is, if you're still looking. The answers above are fine, too, but this is a link to a full reference on the Sound JS module, and the coding examples seemed quite clear and well documented to me.