3

I would like to play a sound when someone click home button of iphone/ipad, e.g. when application goes in background.

I have already added "App plays audio" required background in my info.plist.

I am trying to play an audio file in applicationWillResignActive and applicationDidEnterBackground methods using AVAudioPlayer. But no success yet.

Any solution to this?

Ruchir Shah
  • 898
  • 3
  • 13
  • 31
  • same question like this:-http://stackoverflow.com/questions/7619794/play-music-in-background-in-iphone-using-avaudioplayer – Leena Dec 31 '11 at 09:05

1 Answers1

3

You need to initialize your audio file in didFinishLaunchingWithOptions and play it in applicationWillResignActive.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Tiger
  • 310
  • 1
  • 3
  • 12