简体   繁体   中英

iOS Audio Streaming and save audio file to document directry after audio playing finished

I want to play audio file from server to my iOS app and after audio playing complete want's to save audio to document directry for offline playing.

I have a code to play audio from server. please provide me any code to save file for offline playing.

NSURL *fileURL = // your url.   
myAudioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:AudioFileURL error:nil];
myAudioPlayer.numberOfLoops = -1; //infinite loop
[myAudioPlayer play];

I have got a Streaming kit Frame work for this Audio streaming kit from Github

Play an MP3 over HTTP

STKAudioPlayer* audioPlayer = [[STKAudioPlayer alloc] init];

[audioPlayer play:@"http://www.abstractpath.com/files/audiosamples/sample.mp3"];

And append its data to NSMutabledata to play offline by using this delegate.

Intercept PCM data just before its played

[audioPlayer appendFrameFilterWithName:@"MyCustomFilter" block:^(UInt32 channelsPerFrame, UInt32 bytesPerFrame, UInt32 frameCount, void* frames)
{
  ...
}];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM