Search code examples
audioiphone-4

how to run audio after the application hes entered in backgroundMode in iPhone 4.0


I have tried several forums but still unable to get the answer.. I am developing an application which does radio streaming in iPhone 4.0

Now i want that the audio of the radio must continue even after the application is in suspended state..

Also i have an .m3u file which contains 3 urls of .mp3 So i also want that if one mp3 file finishes in suspending state it must continue with another. I have done the code when application is in foreground but confused how to do this when application is in background state..

Please help


Solution

  • This is wht i have used and worked for me..

    UIBackgroundTaskIdentifier backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
                /* just fail if this happens. */
                NSLog(@"BackgroundTask Expiration Handler is called");
                [[UIApplication sharedApplication] endBackgroundTask:backgroundTask];
            }];
    

    hAPPY cODING...