I am developing an iPhone app for music. I want to give some options to the user so they can listen the song/music by streaming or they can download the music in the app. I know how to stream the audio files in the app programmatically. But, i don't know how to download the audio files in the app and play the audio after download. And also user can pause the download while it is in download. Is it possible to do ? Can anyone please guide me and please share any sample code or tutorial for me? I have one more doubt: Can you please help me to create a folder inside of the app? Please help me. Thanks in advance.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
Yes, you can download audio files and play downloaded files through AVAudioPlayer. I don't exactly know how to pause when downloading, but I have downloaded audios and played. You can download either from ASIHTTP Request or other.
You can follow these links.
Creating a Folder
For every app you have a
Documents Folder
. Any files you use in your app are stored here. If you want to create more directories here, then you'd do something like this:Downloading
If you want to download audio files from the internet, then you want to look at an asynchronous method of doing it. This means that the application can carry on doing things while your download happens in the background.
For this, I recommend you use ASIHTTPREQUEST. It's great for carrying out any download requests, providing you with many options such as pausing a download (as you requested).
The website provides a great deal of documentation on downloading and storing a file. Take a look at the Downloading a File section on this page.
You'd just do something like:
Then just handle the progress and completion through the delegate methods that ASIHTTPRequest offers.
Playing
Playing the file is very simple. Once it's on the device and you know where it is, just load it into the audio player.
There's a great tutorial here on using AVAudioPlayer to play sounds. A very simple example of using it in your case would be: