TMacGyver
TMacGyver

Reputation: 1291

iOS: play sound for duration in background

I wondering if there was a way to play a sound or music for a predetermined duration even if the app is put into the background.

For instance, say the sound is 30 mins long but only want to play it for 10 mins, how can I pause the sound while in the background. Or is there a way to tell AVAudioPlayer to loop 0.333 times?

Is there a better class to use instead of AVAudioPlayer to achieve this?

EDIT: So far I've searched SO and Google to no avail. And have been reading through Apple's docs.

Thanks in advance for the help.

Upvotes: 1

Views: 516

Answers (1)

Max
Max

Reputation: 6394

Two solutions:-

-1. You can have Local and Push Notification

http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008194-CH1-SW1

Notification can play sound when delivered.

-2. You can make you app run in background and play sound

http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html

iOS/iTunes rules limit what you can do in background to pass moderation but it mentions playing music.

Upvotes: 1

Related Questions