Forum Discussion
Restarting audio from the beginning
Hi
I have some audio that starts when the user presses a 'start audio' button.
I have added a 'pause' button. If the user pauses the audio, and then presses the 'start audio' again, the audio continues from where it was at when it was paused.
I want to add a 'restart audio' button that will start the audio from the beginning but I can't work out how to do it. If I add a trigger to play audio when you press the 'restart audio' button, it just plays where the audio was last up to rather than starting it again from the beginning.
Any ideas would be most welcome
Thanks
Sue
27 Replies
- SueWallisCommunity Member
- MaryTCollins-ebCommunity Member
Hi Sue,
I haven't been able to replicate the issue of two audios playing at the same time but what I did find was that if you paused on base layer, then hit restart, then hit pause, it started playing the audio from the base layer rather than the restart layer. To fix this I followed these steps:
- Added a pause/play button to the restart layer and hid the one from the base layer
- Set the initial state to Normal
- Changed the triggers for this button to refer to the audio on the restart layer
- Add a trigger to the restart button to return to 0sec on this layer when user clicks restart again
- Add a trigger to play the audio automatically when timeline reaches 0.25secs
I hope this covers all bases!
- SueWallisCommunity Member
HI Mary
You are an absolute star - thank you so much. I am really grateful for helping me further with this. I will implment your solution straight away.
Thanks again
Sue
- MaryTCollins-ebCommunity Member
No problem Sue, I hope it's all in working order now!
- KennethWheadonCommunity Member
I was wondering if the ability to restart audio through a trigger could be added. The workaround suggested is a great one but doesn't work for all scenarios.
- MariaCSStaff
Hi, Kenneth.
The trigger "Play audio" will restart the audio after it completes or is stopped. So if your design allows, you could add a replay button with the following triggers:
- Stop audio when the user clicks the replay_button
- Play audio when the user clicks the replay_button
Here's an example:
Let me know if that helps!
- KatherineBurrowCommunity Member
Just in case anyone finds this post via Google as I did:
What worked for me ultimately was to do what Leslie originally suggested with putting a duplicate audio file and buttons in a separate layer, but I had to combine it with what Maria mentioned about using the Stop and Start Audio triggers.
As a note, I'm creating a playlist where the audio is set to automatically play when the slide timeline starts, and the user has a play / pause option as well as a skip option (a forward arrow with a "jump to the next slide" trigger).
When the user clicks the back button on the base layer, it does three things:
- A Stop Media Audio trigger activates
- A Jump to Start of Timeline on This Slide trigger activates
- (this may not actually be contributing to the solution but I've got some other things on the slide I also wanted to restart when the song restarts)
- A Show Layer 2 trigger activates
Layer 2 has the same exact buttons and content as Base Layer, but the audio file is a duplicate (Audio1). The properties of Layer 2 are set to "Resume initial state upon return." Like the base layer, Layer 2 has an auto-play trigger for Audio1.
When the user clicks the back button on the base layer, it does three things:
- A Stop Media Audio1 trigger activates
- A Hide Layer 2 trigger activates
- A Play Media Audio trigger activates
- (Audio is the media file on the base slide.)
This returns the user to the base layer, where the timeline has already been reset, and because the media was stopped when Layer 2 opened, it restarts from the beginning with the play trigger.
Because Audio1 is stopped when Layer 2 closes, the button on the base layer that reopens Layer 2 also causes the music to restart on that layer. So it creates an infinite loop of restarting the song when the user clicks the button by taking the user to either the base layer or Layer 2.
Presumably you could also do this with videos or anything else Storyline recognizes as "media," though I haven't tested that yet.
Hope this helps other people! Even with the lovely advice already in this post it took me a solid hour or two to figure it out yesterday.
Hi Katherine,
Thanks for sharing your solution with the E-Learning Heroes community! I'm sure other developers will find this post useful!
Related Content
- 4 months ago
- 10 months ago
- 10 months ago
- 11 months ago