1

I use SystemSound for sound effects in my app, and when I turn the volume down/up on iPhone/iPod the app responds. But when I run the app on iPad it doesn't and plays the sounds on the same volume level. My app got rejected because of this. The message said "Your app did not respond to hardware volume changes when reviewed on iPad." What can I do? Any help appreciated!

2 Answers2

0

As your well aware of this, there is loads of different ways to implement sound into an app. I tend to use 2 different methods, and I'll show you both of them.

Method One - using AudioToolBox

NSString *over = @"SoundName";
SystemSoundID soundID;
NSString *soundPath = [[NSBundle mainBundle] pathForResource:over ofType:@"mp3"];
NSURL *soundUrl = [NSURL fileURLWithPath:soundPath];
AudioServicesCreateSystemSoundID ((__bridge CFURLRef)soundUrl, &soundID);
AudioServicesPlaySystemSound(soundID);

Method Two - using AVFoundation

I would also use .mp3 over .wav as mp3 will be a smaller file!

Michael Mooney
  • 357
  • 3
  • 13
  • I used to use AVAudioPlayers (AVFoundation), but that made my app look laggy... So I switched to SystemSound (AudioToolBox), and that's when the problem occured. The iPad just won't respond to any sound in my app, using AudioToolBox. – спасибо Dec 31 '14 at 10:55
  • Use my audiotoolbox way, my app got accepted with that style of code. However, the app will get accepted but the sound is produced on the ringer which is annoying. – Michael Mooney Dec 31 '14 at 10:59
  • What do you mean produced on the ringer? – спасибо Dec 31 '14 at 11:18
  • The ringer is on the side on a ipad, iPhone ect, if it's not on silent it'll produce the sound at which the ringer is at, and when the ringer is off (closed over) no sound will be produced. – Michael Mooney Dec 31 '14 at 11:19
  • How is that annoying? – спасибо Dec 31 '14 at 11:23
  • You're not using the volume buttons to adjust the sound. – Michael Mooney Dec 31 '14 at 11:25
  • That's what I want to do. I want the user to be able to adjust the sound using the volume buttons. – спасибо Dec 31 '14 at 11:27
  • I know but audiotoolbox doesn't work that way (I think) AVFoundation does work that way tho. Just implement method one a see if it works when the ringer is open, your app should be accepted using that method. And if you really want it to be adjusted via the volume buttons then you need to find away around the lag. – Michael Mooney Dec 31 '14 at 11:30
  • I guess so, but the weird thing is that the volume buttons work on iPhone and iPod, but not on iPad. – спасибо Dec 31 '14 at 11:32
  • There might be a way to solve the lag issue. Looking at your other posts you're using way to many timers without the proper invalidation method - slows the game down. You're using timers to do animation via loads of pictures - loads of lag. I would suggest you use an actual animation. – Michael Mooney Dec 31 '14 at 11:34
  • I think I didn't use the correct way of using AVAudioPlayer that caused the lagging. I didn't use PrepareToPLay for example which didn't let the sounds buffer, and caused the game to look laggy everytime the sound/sounds were about to play. – спасибо Dec 31 '14 at 11:38
  • Updated Answer, your sound problem should be fixed. – Michael Mooney Dec 31 '14 at 13:36
0

I figured out a way. I declared an AVAudioPlayer in the AppDelegate to play a background soundtrack, and I used a silent track. Since the iPad responds to AVAudioPlayers, the other sounds (System Sounds, that I use for sound effects) automatically respond too. I suppose it's not the best solution, but it worked for me.