How do I pause/start music player with one button?

I am trying to pause and start background music with one button. How do we code this? Thanks!

well here is the algorithm for it -

set the button text to start then 
when button click 
if button text = start 
then 
start the player
set button text to pause
else 
pause the player
set button text to start

1 Like

well i told the same thing :sweat_smile:

yes but maybe blocks help more

1 Like

grafik

Note: This yellow marked block is only necessary if the sound is not looped.
If it is looped, there will be gaps between the loops (transitions) with the Player component. To avoid this, you have to use the TaifunPlayer extension and OGG format instead of MP3.

3 Likes

Got it thank you everyone!

2 Likes

i know this is an old post i'm sorry but could someone @EmiratesFan001 @preetvadaliya show me an image from the designer page of this happening and not the blocks please

Hello Hottunez

Just make a test file using the Blocks as shown.

i've done this as shown

Blocks:

have i done this rite with the buttons in designer?

Designer:

You are using 2 Buttons...
The idea of this thread is to use only 1 Button

Taifun

1 Like

so should i remove all thats circled

Try this one: playPause.aia (314.7 KB)

2 Likes

rite were does the aia go

:question: -

You should only use 1 button and not 2

A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook http://www.appinventor.org/book2 ... the links are at the bottom of the Web page. The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro and the aia files for the projects in the book are here: http://www.appinventor.org/bookFiles
How to do a lot of basic things with App Inventor are described here: http://www.appinventor.org/content/howDoYou/eventHandling .

Also do the tutorials Our Tutorials! to learn the basics of App Inventor, then try something and follow the Top 5 Tips: How to learn App Inventor

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

It is best if you work the blocks out yourself. Don't take AIAs for granted. :slight_smile: Also, please do not promote your help topics elsewhere. Wait for a user to read your post and respond.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.