Hello Koders, I need help with a problem, how can I save the files of the SoundRecorder component in numbering order?
ex. mySound1, mySound2, mySound3, etc.
Hello Koders, I need help with a problem, how can I save the files of the SoundRecorder component in numbering order?
ex. mySound1, mySound2, mySound3, etc.
In the saved recording block of sound recorder component you need to set the file path which includes file name, so while storing the filename you need to use a variable, which will be initialized globally to empty string, this variable will contain filename. As you want that the name should be in numbering order, in the after sound recorded block of sound recorder component you need to add 1 to a math variable which will be joined to the filename variable…
So in simple words,
After sound recorded
Set math variable to math variable value +1
Set filename variable to name, join math variable
Set save recording block of sound recorder component to file path which includes filename variable
You could send an example directly with blocks, because I have not understood well.
I am new to Kodular and am still learning. I would be infinitely grateful to you.
Hi, it is not a good idea to show blocks, if I did so, I would stop you from rectifying errors yourself, and learning different things, so you can try and if you face issues we are here to help
Okay, thank you all the same. Now I try.
initialize your math variable with 0 and increment it by 1 to get the next number
you can find the + block in the Math drawer
then put together the filename using the join block
and first set the filename and then start the soundrecorder, i.e. move all these blocks into the button click event assuming you are using a button to start the soundrecorder
Taifun
I entered all the blocks in the event When SoundRecorder .Stopped Recording" and now sorts them by numbering but a new number is added to each new saved file:
Also you can store the number in tiny db and get it on screen initialize so recording won’t be replaced when reopening the application as it will restart the numbering from 0
Can you post your relevant blocks so we can hep you…Did you make what @Taifun and @Soham_Shah told you…
When you record for the first time you set the file name for example to recording1 then you set it the next time to recoding12 as you are joining the file name which you already set…Summary :When you are joining the file name with the math you join the old one as well which is recording1 so it results recording12…
Put a setter block to set the file name to “Recording” again after setting the save recording property
Taifun
Ok, the files are saved and sorted correctly with numbering … when the app is restarted, when I start a new recording, the old files are replaced with the new ones. For this problem I can insert a TinyDB, right? Thank you all for the help you have given me and for your patience.
Right You can see my comment :
Hi everyone, I’m Ragnarok , I created a new account and this old one is in the process of being deleted. I noticed a small problem with the recorder: When I go to delete a recording and create a new one, the latter instead of replacing the deleted one, continues the numbering order … it is possible to create a sort of “mechanism” to solve the problem?
Example:
Recording1
Recording2 (file deleted or renamed)
The next registration is Recording3 but, since Recording2 has been deleted or renamed by the user, Recording3 will become Recording2 and after which the numbering order will be resumed (Recording4, Recording5 etc.)
That could be implemented…
Try this:
I will first initialize a local variable = 0, then inside use while test file exist, add 1 to a variable. After while test, save recording using the local variable
Your way has only one problem…If two sounds are recorded they will be with the same name…Any way its better that it will work without tiny dbd which can be removed in any time by clearing cache…