We have a volume slider on the audio player in our iphone app. It streams music from our server. All is well initially until the point that some bac开发者_运维百科kground operation happens on the iPhone.
Eg: The Mail app downloads new mails in the background and that makes a little audio sound or I receive a new SMS and that gives a little sound alert.
In such cases, the volume of our music player increases or decreases abruptly. The slider stays where it is, but the volume pitch changes. The only way to get where it was before is pause and play again and then the volume re-adjusts.
Any idea how to solve this issue?
Thank you in advance Swap
Sounds like a classic Audio Session Category issue.
Check the Audio Session Programming Guide on Configuring your Audio Session.
Specifically, try to setup your application audio session towards AVAudioSessionCategoryPlayback
.
NSError *setCategoryError = nil;
[[AVAudioSession sharedInstance]
setCategory: AVAudioSessionCategoryPlayback
error: &setCategoryError];
if (setCategoryError) { /* handle the error condition */ }
精彩评论