AudioServicesPlaySystemSound not working on iPad device

大城市里の小女人 提交于 2019-12-05 07:20:50

I don't think you can play an mp3 file on the device using AudioServicesPlaySystemSound. Take a look at the documentation for supported file types. I'm not sure why they play correctly in the simulator, but I had the same issue. Try using AVAudioPlayer instead:

NSError *error;
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[[NSBundle mainBundle] URLForResource: @"sound" withExtension: @"mp3"] error:&error];
if (error)  {
    NSLog(@"Error creating audio player: %@", [error userInfo]);
} else {
    [audioPlayer play];
}

[audioPlayer release];

I came across this question via a Google search. My problem is exactly as stated in the title of this question: "AudioServicesPlaySystemSound not working on iPad device". However, the description of the issue is different.

Simply put, after upgrading my iPad to iOS 4.3, AudioServicesPlaySystemSound stopped working.

I finally found the solution to my version of the issue, so hopefully this helps someone else.

Go to the Settings app on the iPad and choose General. Tap Sounds. Make sure "Change with Buttons" is set to ON. This will fix the issue.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!