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.
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.
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).
Hmm, now something funny is happening. 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.
I was wondering if you would be able to post an image of the final code you used for the single play/pause button that refreshes (as you noted above) and starts from the beginning of the audio recording when users navigate away from the screen and come back later.
I am just a little confused about how to implement the suggestion offered in the post by CBVG that says “…issue a ‘resume’ and immediately call ‘stop’…”