2017년 3월 16일 목요일

Selecting images and audio from list


I am trying to create an app for padi revision for my daughter what i want to happen is when i press next button it loads the next picture in the list and plays the corresponding audio file, i have two lists one for the images and one for the audio files everytime i hit next it increments the list index by 1 and when i press back it takes 1 off the index variable, I use this variable to select the correct image and correct audio file. It doesnt work when i press next nothing happens, can someone point to what i am doing wrong? This is the first thing i have tried to do with app inventor so a little green!
--
are you using both the Sound and Player component?
try to use only the Player component
remove the 2 advanced blocks (a list is not a sound component, this does not make sense like that) 
instead call Player.Stop, then set the Player.Source to the corresponding mp3 file and call Player.Play
you also could use only one index for both lists...

-- 

Music List


I have read the tutorial on how to use a list to play two different audio sounds as one starts the other stops and this is a convenient method for two or three audio sounds however is there a block or blocks that can be used to enable an audio to stop as another one starts to play . I would like to make this:  package several music files as a standalone Android music library Can anyone offer advice 

-- 
You would need to use some logic to test for the player's state.
For example,
if Player1.isPlaying (
Player1.stop
Player2.start
)
Or, if you just use one player, simply changing the player source and then calling Player1.start will stop the existing sound.

--
phantomfoot 
Many thanks for the reply 

--

Deleting recorded audio files


Please SEARCH in this forum before posting your question.   There's a good chance your question has already been asked.

If you are asking for technical help, you must provide the following information:
- Are you using MIT App Inventor Classic, MIT App Inventor 2, or something else (what?)
- What OS are you using? (e.g, MacOS 1.8, Windows 8, ...)
- What browser are you using (e.g, Chrome version 30, Firefox 24, IE 8, ...)
Also provide as much information as you can, such as screenshots and instructions that will let others duplicate the issue.

App Inventor 2
OS Windows XP
Chrome

--
Using the SoundRecorder I wish to record 4 second long audio clips and should there be some external event I wish to keep the file. Should there be no external event I wish to delete the file?

At present I have the SoundRecorder running in a loop and can view the file name and where it is saved. Is this a limitation of AppInventor 2?

-- 
you can't delete files with MIT App Inventor
probably the personal servers can do that

-- 
There is no way with AI2 to directly save or delete files stored on an Android device.  However, there are ways of managing and deleting files using external file management apps.  With these, you can delete and add files to a folder.  Here is a link to a page that discusses what might be available for your phone or tablet on Google Play:    http://www.labnol.org/software/file-manager-android-apps/28285/   .   With one of these you can delete files if you know the folder they are in.  However, be CAREFUL; an app like these has the ability to delete almost anything so before you use it to delete anything, be sure you understand how the app works.

The MIT programmers are working on a way to save and load files.  It is not yet ready.   Perhaps it will also include the ability to delete files.

--
So I'm guessing I could write the file addresses (appinventor) and if they should be saved or deleted to a database and then run a second program (Java?) in the background that reads the database and deletes the unwanted recordings. 

I would then hopefully have up to 4 seconds of saved audio before the event, audio throughout the event and nothing else till the next event occurrence.   

--
I'm struggling to get to grips with the "AfterSoundRecorded" function as this seems to automatically save the recorded audio file. From this I use "get sound" to find the location the file has been stored at. 

Is there a way of stopping the file being saved?
Is there a way of changing its "Save As" /"Save to" location?

Thanks for any explanation of how this works 

--
see a sound recorder example here  How to use the Sound Recorder
this component only offers some basic functionality
soundrecorder.aia

Is there a way of stopping the file being saved?
no
Is there a way of changing its "Save As" /"Save to" location?
no

--
The Sound Recorder is very simple as Taifun mentioned. His blocks show how to use it.  However, if you use the sound recorder blocks  in conjunction with a TinyDB you might be able to get some of the functionality you desire.  The idea is to save your recordings in a TinyDB, then you have the ability to select them and to DELETE them.

This App Inventor Classic example by Jason Tyler about saving sounds to a TinyDB:  http://www.youtube.com/watch?v=hKTPSXSccMo     seems to show some of what you need.


You can save a recording(s) to the TinyDB .   Call the sound MySound, then save it to a TinyDB tag called MySound.  The sound is in the TinyDB.     You want to delete it?   I think you can then delete the tag with a "call TinyDB1.Clear Tag  block where the Tag equals MySound.       Not exactly what you are looking for, however you now have a way to DELETE sounds stored.     SaveAs  could be simulated by saving each sound file as a value in the TinyDB.  You provide a name for each sound which is also the name of the Tag it is saved under.    Does this make sense?

So, Is there a way of stopping the file being saved?     Probably Not directly.  Might be able to immediately delete it though..
Is there a way of changing its "Save As" /"Save to" location?    Yes, but not directly but you can do that using a tiny db and get the ability to delete it.

Try using TinyDB to save the recordings.  Be sure to view the you tube video.  The blocks are different but the ideas here are seem to be what you need in you app.

--
It seems to me, you should be able to save a recording to the TinyDB .   
the sound is always stored on the sd card, what you can store additionally is a link to the sound in TinyDB as in that example

--
Thanks chaps, not quite there yet but getting closer and getting a better understanding of app inventor

I haven't tried saving the audio to the TinyDB. 

At present it goes to its default location, something like this /mnt/sdcard/My Documents/Recordings/app_inventor_1392845817634.3gp which I guess is decided by SoundRecorder. I'm saving this prefixed by a time date stamp to the TinyDB and adding it to a list Blocks Image.



--
OK, thanks for the update.  I would like to comment regarding the blocks you posted on the link, however the image resolution is such that it is unreadable here.  Sorry.

How about a better image?    

What you are doing sounds reasonable in principle.   I guess you are using the time/date as a tag?

-- 
To delete recordings I wonder if it is possibly to delete unwanted files using "ActivityStarter"?

I can find the address/location of the files to delete from my "List". Would it then be possible to pass these to the "Shell" rm app_inventor_xxxxx.3gp using "ActivityStarter"?

If this is the way to go, how do I launch and pass the address/location to the Shell?

If there is a better way I am eager to hear it.

--
To delete recordings I wonder if it is possibly to delete unwanted files using "ActivityStarter"?

I can find the address/location of the files to delete from my "List". Would it then be possible to pass these to the "Shell" rm app_inventor_xxxxx.3gp using "ActivityStarter"?
this depends on the file manager you are using, probably AndExplorer can do it?

                       Example: Picking files from the SD Card

Here's an example that illustrates using a third-party application:
AndExplorer from Lysesoft is an application that lets you pick files for your SD card. You can call AndExplorer with an activity starter to add a file picking capability to your application. You'll need to have AndExplorer installed on your phone. You can get it from the Android Market.                     

an example to pick files from SD card, this could probably be adjusted to your needs http://puravidaapps.com/pick.php pick.aia
or you wait, until the file component is available in AI...

--
Thank you for the info, interesting, I will create some code to see if it will do what I want.

My plan was for my app to each hour get the list of files to be deleted and delete them in the background using Shell code and then close. An hour later it would repeat.

Do you have any idea when the file component will become available in AI?

--