mattgallagher / AudioStreamer

A streaming audio player class (AudioStreamer) for Mac OS X and iPhone.
http://cocoawithlove.com
1.93k stars 553 forks source link

AVAudioSession + Enabled Background Mode #90

Closed ashleyevans closed 2 years ago

ashleyevans commented 10 years ago

I've tested background mode and phone call interruptions and both seem stable to me but would appreciate some more testing

changes made were based on the work by http://github.com/software-mariodiana/AudioBufferPlayer/wiki/Replacing-C-functions-deprecated-in-iOS-7

keab42 commented 10 years ago

You need to make some modifications to iPhoneStreamingPlayerViewController.m so that the streamer can respond to play/pause events from Control Centre

It needs to declare in the ViewDidLoad:

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];

You also need to add the canBecomeFirestResponder method and set it to return true, and in viewWillDisappear:

[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[self resignFirstResponder];

You'll also need a - (void) ReceivedWithEvent:(UIEvent *)event method somewhere in the class to handle those play/pause/stop events.