Play + Pause, same button

Hello! I am trying to use 1 button to play music, then the same to pause it and play again. I would like to change the text (or swap a background image) when this happens. I see the options within thunkable, but I’m having trouble putting these blocks together correctly. Nothing I try seems to work.

This is what I have, but I can’t figure out how to pause the audio and change it back to play with the “play” text afterwards.

Many thanks for your help!

Hey @looovelee,

Something like this should do the trick:

1 Like

Thank you so much for your help!

I don’t think I did a very good job of explaining my goals here. :wink:

I am looking to have a play button (left), when clicked this button plays music and instantly changes into a pause button (right) for ease of use. When the user uses this button a 2nd time, it will act as a pause button. As soon as it is clicked the second time, it is now back to the original state (left) of “PLAY”, so the user can use it again to play the media.

What I’ve been able to do so far is have the text change to pause and the media to start on 1st click.

I can’t seem to figure out how to make the 2nd click recognise it is now a pause button? I want it to pause media and return to “PLAY” text or image.

Does that make sense? :slight_smile: Many thanks!

There’s an example of this in the 4th post.

if play.jpg
set bg_image to pause.jpg
set bg_image to play.jpg

What you need is something like this:


Each time someone clicks the PlayPause button, the value of “pause” changes from true to false, or from false to true.
Then it is only a matter of using the if/else logic block to change the image displayed and to perform the actual playing and pausing. Just be careful which is which, as the changing is done BEFORE it is acted on, so may be the reverse of what you would expect (but since it is a pure if/else, that is easily seen and corrected).


This is perfect! Exactly what I was looking for here. That all makes such clear sense now and it works!

Thank you so much for the help and clear explanation.

Thank you for your help!

Hmm, now something funny is happening. :sweat_smile: Sorry to bother you again, but I do appreciate your help.

When I play the media and depart that screen, the music will start from the beginning the next time I click play. However, if I click play and then pause it with the pause app (Which works beautifully!) and then navigate from the screen it will play again from the point where it was paused.

I would prefer that when the user opens the media screen they have a brand new session - if that makes sense. Everything on this screen should start fresh.

I thought by making the close button call stop that would reset the media. This only works if I have not used the “pause” app.

Apparently, the ‘pause’ function is keeping track of where the playing was at the time, and disregarding anything but a resume command.

So, my suggestion is that, if you leave the media screen, you issue a ‘resume’ and immediately call ‘stop’.
As the two functions would be one after the other, they would run in a fraction of a second, and no real music would have had the time to play before the playing is overall cancelled.
Sometimes, you have to adapt your code to the limitations imposed by other choices.That would be such an instance.


Perfect solution! Thanks a million!


A post was split to a new topic: Create a music playlist