I'm having trouble with one of my animations.
I have set up 8 animated symbols that will play when the user hovers over the symbol.
When the user clicks on a symbol it will play an audio mp3 files.
// insert code for mouse click here
// Sets a toggle to play or pause the audio track
var audio = sym.$("_1")[0]; "_1" is the name of the audio file that is placed on the timeline. The original MP3 file is named 1 but when it was dragged to the canvas it created a layer called "_1".
if (audio.paused) {
audio.play();
} else {
audio.pause();
}
But there are two problems, one more concerning than the other.
The problems are below:
I can not figure out the code to stop the audio when the symbol is clicked again instead of it being paused. I tried to change audio.pause to audio.stop. That did not help. I would like the audio to stop if clicked again and then play from the beginning if clicked one more time.
This is the one that I am most concerned about. If the user clicks on one symbol, the audio for that symbol will start to play as intended. But if the user clicks on a second symbol, the audio for that symbol will start to play in conjunction with the audio already playing from the previous symbol. It would be nice if a user could click on one symbol it will start to play its audio but if they change their mind and click on another symbol, the playing audio will stop and the new clicked symbol will start to play its audio.
Anyone have any suggestions? Or help to provide. Thanks in advance.