Reputation: 1291
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
Reputation: 6394
Two solutions:-
-1. You can have Local and Push Notification
Notification can play sound when delivered.
-2. You can make you app run in background and play sound
iOS/iTunes rules limit what you can do in background to pass moderation but it mentions playing music.
Upvotes: 1