Recording and Saving sounds

I have been looking around for a while but unable to find some sample code on recording and saving a sound back to the App resources. Appreciate any examples or direction.

You won’t be able to save back to the app resources. Everything in the bundle is read only. Try saving into Documents or the ApplicationData folder.

What control am I using to grab the sound or does that need to be done with declares?

It needs to be done with declares, but I’m pretty sure iOSKit had the necessary code for it

2 Likes

Example view: https://github.com/kingj5/iOSKit/blob/master/ExampleViews/AVFoundationViews/RecordPlayAudioView.xojo_code

1 Like

Thanks Jason, found it.
If I want to save the sound how would I do that? I have tried saving data before and it seems really difficult to find it again on mobile devices

The example view saves in the app documents folder (SpecialFolder.Documents). You could make a sub folder called “recordings” and save all of the recordings there as an example.

1 Like

You would have to make your own dialog to read the contents, is that correct?

Can you download projects in GitHub? I can’t find where.

Can someone spot my error?
Output is Nil

Dim saveTextFile As FolderItem = SpecialFolder.ApplicationSupport.Child(MyData.txt)
Dim saveImageFile As FolderItem = SpecialFolder.ApplicationSupport.Child(MyData.png)
If saveImageFile <> Nil and my picture<> Nil Then
  mypicture.save(saveImageFile, Picture.Formats.PNG)
  
  If saveTextFile <> Nil Then
    Var output As TextOutputStream = TextOutputStream.Create(saveTextFile)
    output.WriteLine(NameTF.Text)
    output.Close
  End If
End If

Yes you can download them, or if you use git you can clone them

You cannot use ApplicationSupport on iOS. Try Documents instead. See here:

ApplicationSupport works for me but only if I create the folder if it doesn’t exist.

3 Likes

I guess it’s doable, I just can’t find the download button/link.

Green code button (click) and download zip is one of the menu options

1 Like

Good to know, might look into using it again. I’ve just been putting everything in sub folders of Documents due to the issues from years back.

There may be more to read here about the ApplicationSupport folder missing, this is most likely a default setup by the ios sanbox.

Yes the ApplicationSupport needs to be created if not already exsiting. Xojo could add that to their docs maybe since this is kinda a year long trial and erro thing now.

Currently there is nothing about it here http://documentation.xojo.com/api/files/specialfolder.html

2 Likes

I saw it here back in November SpecialFolder issues

1 Like

Ah, using your link, it was rather obvious, thanks.
@Jason_King’s link led to a page without that green button. And one reason I dislike GitHub is exactly that: it’s a maze.

Feature request in feedback :wink: