I'm new to audio handling in ios. 1.I want to know that if I have web server on which I have some audio files. And through my iOS application user can play that file, allow them to forward or reverse functionality, pause etc. 2.And when user click on "Home" button sound file not pause or stop at that time, file play in background uptill user not close the application properly...
main thing is application play file online and not whole file download on user device
if any of the one answer is possible plz help
Thanks
Streaming Audio Services is possible. you should using a AVPlayer
(not AVAudioPlayer
AVAuioPlayer
is not available Streaming Services.)
This apple Sample Code StitchedStreamPlayer is good for you.
This code Streaming Movie Play Sample, but also available Audio Service.
Your best bet is to user this github project https://github.com/jfricker/AudioStreamer You can control forward and reverse for audio in it. I have used this in one of my project and the performance is really good.
after searching things here I'm with answer.for run application in background playing songs, step is as below
in your .m file
- (void)viewDidLoad { [super viewDidLoad]; NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"select" ofType:@"mp3"]]; NSError *error; audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil]; if (error) { NSLog(@"Error in audioPlayer: %@", [error localizedDescription]); } else { [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil]; [[AVAudioSession sharedInstance] setActive: YES error: nil]; [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; [audioPlayer play]; } }
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.