How to make auto Sound play one time after connect to Bluetooth?

83 views
Skip to first unread message

Moosa Alismaili

unread,
Oct 14, 2019, 5:58:40 PM10/14/19
to mitappinv...@googlegroups.com
  Hi dear I want to make sound run as welcome to my app . When connect the Bluetooth after 15 second start run sound one time only then stop  to use the application as normal 
thanks for help
222.jpg

Moosa Alismaili

unread,
Oct 14, 2019, 6:13:54 PM10/14/19
to MIT App Inventor Forum
Without push button

RBG

unread,
Oct 14, 2019, 6:25:43 PM10/14/19
to MIT App Inventor Forum
Hi
You can add a player component, assign a sound and after from blocks Page when the timer is 0, call to player

Can you try this?

Regards

Moosa Alismaili

unread,
Oct 14, 2019, 10:57:49 PM10/14/19
to mitappinv...@googlegroups.com
You can explain more or by example I'm beginner in this application . 

RBG

unread,
Oct 15, 2019, 2:56:46 AM10/15/19
to MIT App Inventor Forum
Can you attach your aia File?
There is a component how clock, and others in the list.
You can try add the player component to your compilation, in the settings of this component you can set the sound.mp3, wav etc that you want play.
After in the Block screen, you can put how is now.
When the timer...if Bluetooth is conect
Set label1.....
Call player

But if you can please attach your aia File and before of go to work this afternoon,I will try see it

Regards

BodyMindPower

unread,
Oct 15, 2019, 4:33:33 AM10/15/19
to MIT App Inventor Forum

Moosa Alismaili

unread,
Oct 15, 2019, 7:16:56 AM10/15/19
to mitappinv...@googlegroups.com
Thanks more 
 I try still not work I get the sound but repeat again  I want run one time only  
test.aia

Moosa Alismaili

unread,
Oct 15, 2019, 7:23:40 AM10/15/19
to MIT App Inventor Forum
I try this not run one time 

Chris Ward

unread,
Oct 15, 2019, 7:38:44 AM10/15/19
to MIT App Inventor Forum
Hi Moosa

Just use a Boolean variable. SoundPlayed = False. Put you Play Sound Block inside an IF that tests the variable: If SoundPlayed = False - play the sound, set the variable SoundPlayed to True.

Moosa Alismaili

unread,
Oct 15, 2019, 8:57:44 AM10/15/19
to MIT App Inventor Forum
Thanks Chris Ward you can help us more I'm beginner in Mit App you can do it to me or give to us an example  

Chris Ward

unread,
Oct 15, 2019, 10:48:48 AM10/15/19
to MIT App Inventor Forum
Hello Moosa

Well, we do not know much about your Project, your code does send or receive any data. You are using Bluetooth Classic, I hope you have checked that the device you wish to connect to uses the same.

See the attached. It shows how to play the sound just once. It also shows how to give the attempt to connect a little time (1 second). Usually connection is immediate, but not 100% of the time.

Also, I show the code needed to ensure that the Phone actually has Bluetooth enabled.

Sorry but I'm unavailable now, I am working on a commercial Project.

blocks.png


Right-click on the above Blocks Image to view full size in another Browser Tab.
PlaySoundWhenConnected.aia
Reply all
Reply to author
Forward
0 new messages