IPhone SDK: Save Streaming Audio File to Documents Folder

I want to save the audio file in the Documents folder of my application, while one of the classes in my application transfers it. How can i do this?

Can I save streaming audio directly to mp3? (if the sound file being broadcast is mp3 or do I need to use caf?)

Thank.

<i> Edit: what if I run the save on another thread and the user exits the application? I know that the application cannot run in the background on the iPhone, but is there a way to stop the download and delete the partially saved file when the user exits the application? Can I get an exit signal inside a class or delegate for NSURLConnection?

+2
source share
3 answers

If you use NSURLConnection or CFNetwork to download the file, you can save it in the connectionDidFinishLoading.

Take a look at Matt Gallaghers MP3 Streaming and Playback

+1
source
(void)applicationWillResignActive:(UIApplication *)application
{

}

Write your code in the above method in the application delegate file.

+1
source

If you want to clear a partially saved file on exit,
you can do worse than doing it from

- (void)applicationWillTerminate:(UIApplication *)application

in your application controller.

0
source

Source: https://habr.com/ru/post/1792428/


All Articles