Audio Stop/Start Replay

Apr 27, 2021

Hello. On this slide, I want the audio to begin playing when the user hits play, and pause when the user hits pause (same button). I've set up a toggle switch and states to change between play/pause. I've followed instructions (copied/pasted) from another e-Learning Heroes discussion for how to make this work.

However, I can't get the "pause" state to remain visible when the music is playing.

Additionally, the restart button should send them to the restart layer to start the music again (which is does), but there are also some problems with the pause/play functionality on the restart layer. Sometimes you will hear two tracks of music playing.

Can someone help me with what I'm missing here? Or is there an easier way to accomplish what I'm trying to do?

Thank you for your help with this.

10 Replies
David Schwartz

Hi Meg,

There were a few things here that were causing an issue. I simplified by having the restart button stop the base audio and then play it, rather than having a separate layer with another copy of the audio. Also, disabled the hover trigger for the Pause/Play button. It's not necessary as the hover state works automatically, and in this case, the trigger was preventing the appropriate state of the button from displaying. 

I changed the default value of the AudioOn variable to false, so it's true when audio is playing.

I also added a couple of triggers to change that variable and the state of the Pause/Play button when the audio ends, so that the user can hit the play button again if they want.

 

Meg Lassiat

Thanks so much, David -  this is exactly what I need. I'm relatively new to using SL and it's helpful to find the simpler solution. The slide I copied from had used a shape as the play/pause button rather than pre-built button, so that makes sense on the hover. I appreciate your help with this!

Meg Lassiat

Hi, David - I've been playing with this and noticed one more glitch. When I hit the restart button, the music immediately restarts (which is the way I want the slide to function). However, when I hit the play/pause button the first time after hitting restart, the music will not pause. I have to hit play/pause twice to initiate the play/pause function after I've hit restart. Play/pause works fine before hitting restart, but once I hit restart I get this glitch where I have to hit it twice before it will initiate. Thank you very much for your help with this - this slide has been a challenge for me!

David Schwartz

Hi Meg,

You just need to switch the true/false triggers for Pause/Play, as shown below. They're reversed, which is why it needs two clicks. Also, I see you changed the default value of the AudioOn variable to True. I would change it back to False, as the audio is not playing when the slide opens, only when the play button is clicked. I noticed that otherwise, it took two clicks to make the audio play initially.

To be clear, the arrows below represent the way they variables should be set.

 

Meg Lassiat

Thank you for your continued work on this, David. I've followed the triggers you have listed above, and now I am having the opposite problem. When the slide first starts the audio is stopped (which is correct). However, I have to hit the play button twice to get the audio to start playing. And then the toggle image is reversed of what it should be. The restart function is working correctly. Initial play is now not working correctly. I do appreciate your continued help and have attached the slide again.