Simple Sound Recorder app

1,000 views
Skip to first unread message

bossxero

unread,
Apr 6, 2017, 2:52:06 PM4/6/17
to MIT App Inventor Forum
Hello everyone, 

I am writing a small simple sound recorder app with the AI2.  I have attached the code as screenshot. 

The aim of the program is to record some audio but I do not intend to keep the audio file or save it. I want to have the file written over or deleted everytime I press the record button to initiate a new recording.  However I am not able to achieve this and the first recording remains and is not deleting or overwritten.  Please check the code and advise me what am doing wrong. 

Thank you beforehand.


Ghica

unread,
Apr 7, 2017, 12:53:25 PM4/7/17
to MIT App Inventor Forum
It seems to me that you somehow are using different filenames for playing and recording.
If you do a delete sound, you should use your soundLink global variable, which you are setting after recording something.
http://ai2.appinventor.mit.edu/reference/components/media.html#SoundRecorder
Cheers, Ghica.

bossxero

unread,
Apr 7, 2017, 4:42:37 PM4/7/17
to MIT App Inventor Forum
Hello Ghica,

Thank you for your kind reply.  I have edited these two blocks and in order to be able to use the sound link that was used.  However, when I am recording, it is not deleting any of the files, each new recording is creating a new file.

My bigger project is an education language app which am working on.  In the reading section, the user(children mostly) will have the opportunity to listen to words and then record their own reading of the words and listen to it.  Since it will be used by children, I assume they will record many many times and over several uses, the recording files will stack up in the storage and will become a problem. That's why am looking for this solution.  basically I want to record an audio, play it and they next time I press the record button, delete the previous recording, then record the new one.  I hope I have clarified a bit what am trying to achieve.  Please look at the attached blocks.  Still not working. No file is being deleted.

Taifun

unread,
Apr 7, 2017, 4:57:59 PM4/7/17
to MIT App Inventor Forum
according to the documentation http://ai2.appinventor.mit.edu/reference/components/media.html#SoundRecorder

SavedRecording
Specifies the path to the file where the recording should be stored. If this proprety is the empty string, then starting a recording will create a file in an appropriate location. If the property is not the empty string, it should specify a complete path to a file in an existing directory, including a file name with the extension .3gp.

The aim of the program is to record some audio but I do not intend to keep the audio file or save it. I want to have the file written over or deleted everytime I press the record button
did you try to keep the blocks as simple as possible and just overwrite the existing audio file?
just set the filename (property SavedRecording) and start recording and next time you start recording, the existing file should be overwritten

Taifun

Taifun

unread,
Apr 7, 2017, 10:03:42 PM4/7/17
to MIT App Inventor Forum
see attachment for an example 
Taifun


soundrecorder.aia

bossxero

unread,
Apr 8, 2017, 6:22:14 AM4/8/17
to MIT App Inventor Forum
Thank you for your kind reply with concrete examples. It helped me to solve the issue I was having and now I am able to achieve the functionality I wanted. Thank you once again.  However I wish to add something in case this might help anyone.  The solution you proposed, I tried it before and it did not work.  I copied the blocks exactly as yours and it still did not work. I downloaded you example aia and compiled it. Yours was working and mine was not.  This left me scratching my head... then I figured it out.  It was related to the media component.  I was using the Sound component and you used the Player component.  The whoel issue arose because of this component.  This was the very first mistake i made and this prevented the program to function as expected.  I need to read more on the difference between the Sound component and the Player component.

Thank you once again for your help and guidance.
Reply all
Reply to author
Forward
0 new messages