简体   繁体   中英

AVAudioPlayer works fine on iPhone, but doesn't play on iPad?

Greetings,

I have an app were the sounds play find on iPhone but on iPad..no sound at all.

Here's a code snippet:

self.player = [[AVAudioPlayer alloc] initWithContentsOfURL: [NSURL fileURLWithPath:filePath] error:nil];
[self.player play];

Any hints as to why no sound on iPad? Other apps on the same iPad play sounds fine. And/or ways to track down the error?

Ok My mistake. I have 4.2 on my iPad, where the orientation switch now is the mute switch. However, the iPod application doesn't obey the mute switch.

Thanks for the suggestions.

您确定NSURL方法调用返回非零结果吗?

I had same problem while I was deploying to ios 3.x.

iPhone 4 & iPad

worked fine with my .wav file

iTouch

didn't worked at all through my ear phone

Here is good way to check and fix your problem

1) Check the file location. (NSURL)

2) Convert into Apple's recommend '.caf' sound format.

Finder->Type 'Terminal'-> Inside terminal Go to the where .wav file locate->Type 'afconvert -f caff -d LEI16@11025 inputfile.wav outfile.caf

3) Maybe you didn't import AudioToolBox framework library.

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