Skip to first unread message

Rafael Garrido

unread,
Feb 17, 2018, 5:59:48 PM2/17/18
to mitappinv...@googlegroups.com
Hello, i´m new at this of making an app and maybe ther´s a very simple solution for what i need, but i have search and can't find any hints. Any help that you can give me will be very welcomed

I'm making a very simple app for myself in app inventor 2; Theres a button in the middle of the screen, every time I push it, it plays a sound that I put in with the "Sound" media component. No matter if the sound is already playing, if I push the button, it plays the sound over the sound already playing, being that exactly what I want, and i have to say, I'm very happy with the results that i've got so far. The only problem is that the sound is 40 seconds long, and the "Sound" Component plays only the first 10 seconds or so, so I'm now using the "Player" component instead and now it does play the full legth of the sound file, the problem now, is that to play the sound again, I have to wait that it finishing playing the whole 40 seconds to play it again, and it lost its charm of playing the sound whenever i want, even if i want it to sound over the sound already playing. 

I hope that I explained myself clearly

Any ideas of what should I do?

I'll apreciate any comments that you have about it

Thank You!!

TimAI2

unread,
Feb 17, 2018, 6:36:09 PM2/17/18
to MIT App Inventor Forum
Use two players: (even better use two audio files with same content but different names, if you can)


Rafael Garrido

unread,
Feb 18, 2018, 2:27:44 AM2/18/18
to MIT App Inventor Forum


Thank you for your answer!

Everything I've done so far is this because i don´t know what you mean by "Button 2" and "Button 3". I'll be honest and tell you what my app is about. I´d like to use it for medatiting, The sound is the sound of a Meditation Bowl, so there´s this giant button on the center on the screen because I plan to play the sound while i got my eyes closed, there for, everything should be done in this one giant button and i´d like that everytime i touch it, it plays the sound over itself because at the begining of my meditation I tend to play it quite continuosly.

Thanks for what you shared, to this point, I can get that a second sound plays over the first one, but from there, i tried some things that i thought could work but it didn't. It's there some next step that i could do?

Thank you!




TimAI2

unread,
Feb 18, 2018, 4:58:19 AM2/18/18
to MIT App Inventor Forum
I just put those there to check that both players were playing, by being able to stop each one. You probably don't need them in your app :)

You need to put your Player1.Start inside the if statement with an else block, as per my example, not like the blocks you have posted.

Rafael Garrido

unread,
Feb 18, 2018, 5:53:05 AM2/18/18
to MIT App Inventor Forum

Maybe I'm misunderstanding your last post. This is what i´ve got now and still only plays two times :(



TimAI2

unread,
Feb 18, 2018, 7:05:59 AM2/18/18
to MIT App Inventor Forum
That is what you asked for in your original post :)

Click button>play sound>click button>play sound over sound already playing

Do you want this to happen continually, so if you click just once, the sound will keep playing again and again and again?

If so you will need a clock timer for that, with the timer set for less than the length of the sound

If you need an example please reply. 

TimAI2

unread,
Feb 18, 2018, 8:12:36 AM2/18/18
to MIT App Inventor Forum
Something like this:


Rafael Garrido

unread,
Feb 18, 2018, 2:19:47 PM2/18/18
to MIT App Inventor Forum
Thank you for your elaborated answer :) altought that´s not exactly what i´m looking for. What im looking for will be somthing like:

Click button>play sound>click button>play sound over sound already playing>click button>play sound over sound already playing>click button>play sound over sound already playing... 

I mean, every time I press, it should play the sound over the sound already playing. To this point, after I press the button the second time, I have to wait till the 40 seconds ends if not, even if I press it, it won't sound.

My bad if I didn't exprees myself clearly enough the first time

TimAI2

unread,
Feb 18, 2018, 3:08:57 PM2/18/18
to MIT App Inventor Forum
How many sounds do you want playing at once? 2,3,4, infinity (you will run out of memory at some point ;) ) ?

If you want more you just have to expand the if/else blocks and the number of players, but i reckon AI2 might start getting upset at some point...

Rafael Garrido

unread,
Feb 18, 2018, 4:26:30 PM2/18/18
to mitappinv...@googlegroups.com
I attach a file that shows basically what i want, notice that everytime that the white circule appears is a touch that i give to the button, i put that in there for illustrative purposes. That's the app that i had previously done with the "Sound" media component, the only problem with that app that i already made is that the sound ends abruptly instead of fadding naturally becuase the Sound component only support short audio files, so i´m trying to do the same thing with the Player component.

"If you want more you just have to expand the if/else blocks and the number of players, but i reckon AI2 might start getting upset at some point..."

Can you be a little more illustrative on what you mean by that, because i´m trying things like this and isn't working





 
ScreenRecorder_20180218-163157.mp4

TimAI2

unread,
Feb 18, 2018, 8:31:58 PM2/18/18
to MIT App Inventor Forum
It gets more complicated with three players :)
We need to ensure that a new player is started every time you hit the button
I believe I have worked through the logic on this, but if you get all three players playing, nothing will happen until one of the players stops.


Abraham Getzler

unread,
Feb 19, 2018, 10:09:37 AM2/19/18
to MIT App Inventor Forum
Once you reach 3 of anything, it becomes simpler
to recast the problem for a large number n.

See attached for how to do it with any number of players.
The cacophany.wma file is a Windows recording of the effect.

ABG

cacophany.wma
row_your_boat.aia
rowyourboat.mp3
blocks.png

TimAI2

unread,
Feb 19, 2018, 10:37:26 AM2/19/18
to MIT App Inventor Forum
^^^^   :)

Larry Deack

unread,
Feb 19, 2018, 1:37:25 PM2/19/18
to MIT App Inventor Forum
:-)

Message has been deleted

Rafael Garrido

unread,
Feb 20, 2018, 5:29:48 AM2/20/18
to MIT App Inventor Forum
Hello! Sorry that I hadn't answered before, but I was a little busy.

Thank you all for you answers!

Abraham Getzler, thank you for your elaborated answer. I used the aia file that you provided as base to make my own.

I noticed that, being new at this, I wouldn't have found the answer on my own, so I couldn't have done it if it weren't for you guys

Thank you very much!!
Reply all
Reply to author
Forward
0 new messages