How can I create a play/pause button, so that when I click on it, it changes from the pause icon to the play icon and when I click on it again it changes back?
You could use a trigger that toggles a variable. Then, based on the value of this variable you would change the state of the button and play/pause media, eg. audio. here is a quick sample.
Instead of changing the state of the button use a normal/selected state which will toggle and not need triggers, otherwise it is the same as Michaels solution
Michael, I would still need toggle the variable to decide whether to play or pause, just wouldnt do it to change the state as well
I have this same element running through a project with 100 videos, I have to remember to set the variable to false each time the slide loads so the play button and variable are in synch.
No difference in the way we do it (I think) I just have a couple less triggers
I'm very grateful, I'll try to do it without some triggers. I'm really glad with your example.
I had been trying for a long time to create this buttom, because I guess that this buttom is very friendly and I'll promise not forget to use the triggers's conditions.
I've created a tutorial: Create a Play/Pause Toggle Media button. The page with the video also includes a link to a sample story in a different thread here in the community.
I followed the instructions on your tutorial but my button is not changing states... when you explain this part you kind of say that it will change states automatically.. mine isn't. Don't I need another two triggers to make it change states back and forth?
HI, I got it to work but I had to add two more triggers than are shown in that tutorial to change the state of the button according to the variable being either true or false. I'm wondering if she needs to add that step to her tutorial or if I am missing something. Thanks Wendy!
Ok it wasn't' working for me so I'm assuming I needed to reorder my triggers? What order should they have been in? I had them the same as the tutorial.
15 Replies
You could use a trigger that toggles a variable. Then, based on the value of this variable you would change the state of the button and play/pause media, eg. audio. here is a quick sample.
Instead of changing the state of the button use a normal/selected state which will toggle and not need triggers, otherwise it is the same as Michaels solution
Phil, thanks for reminding me of the simpler normal/selected state option. My brain seesm to be hardwired to immediately go for variables
Michael, I would still need toggle the variable to decide whether to play or pause, just wouldnt do it to change the state as well
I have this same element running through a project with 100 videos, I have to remember to set the variable to false each time the slide loads so the play button and variable are in synch.
No difference in the way we do it (I think) I just have a couple less triggers
I'm very grateful, I'll try to do it without some triggers. I'm really glad with your example.
I had been trying for a long time to create this buttom, because I guess that this buttom is very friendly and I'll promise not forget to use the triggers's conditions.
Thankyou Phil and Michael.
Hi Jorge,
I've created a tutorial: Create a Play/Pause Toggle Media button. The page with the video also includes a link to a sample story in a different thread here in the community.
Good luck!
Hi Rebecca,
I followed the instructions on your tutorial but my button is not changing states... when you explain this part you kind of say that it will change states automatically.. mine isn't. Don't I need another two triggers to make it change states back and forth?
Hi Karin
have you created the 'selected' state? could it be your trigger order?
Can you screenshot your triggers or upload the story file
HI, I got it to work but I had to add two more triggers than are shown in that tutorial to change the state of the button according to the variable being either true or false. I'm wondering if she needs to add that step to her tutorial or if I am missing something. Thanks Wendy!
Sorry, yes I had created the "selected" state but it didn't change states automatically for me- is it supposed to be preprogrammed to do so?
Hi Karin
once you add the selected state you don't need to add triggers as the built-in states are auto coded so SL knows what to do.
e.g. click an object will select it, click object again will deselect it
See attached sample
1 variable, 3 triggers
Hi Wendy,
Ok it wasn't' working for me so I'm assuming I needed to reorder my triggers?
What order should they have been in? I had them the same as the tutorial.
The order as per my sample file.
Do you want to upload your story file and I can take a look for you - might be easier to modify the setup you have.
You'll need to come into the forum to upload your file - it won't attach if you are sending via email.
Hi Wendy,
thanks for this! Yep my order was different- need toggle above Play and Pause triggers. Thank you for this. All good now!
Hi Karin,
Triggers and their order have tripped us all up! You may want to take a look at this article for a reminder of the order in which they'll execute.
This discussion is closed. You can start a new discussion or contact Articulate Support.