Running Tasks in background with MPMedia

I'm developing an app that switches music using a MPMusicPlayerController.systemMusicPlayer() from the MPMedia framework. I need the song to change anywhere between 30 seconds and 1 minute for up to 100 minutes when the app is in the background. In the foreground of course everything works exactly how it should but in the background I can get the app to do this for about 3 minutes which seems to be the limit imposed on background tasks in iOS8. Is there a way to extend the allowable time that app can operate in the background?


I'm currently using the following code to register the background task where background_task is of type :

var background_task: UIBackgroundTaskIdentifier = UIBackgroundTaskInvalid


func registerBackgroundTask()

{

println("Background task registered")

background_task = UIApplication.sharedApplication().beginBackgroundTaskWithExpirationHandler

{

[unowned self] in

self.endBackgroundTask()

}

}


and then this ends it:


func endBackgroundTask()

{

NSLog("Background task ended.")

UIApplication.sharedApplication().endBackgroundTask(background_task)

background_task = UIBackgroundTaskInvalid

}

Running Tasks in background with MPMedia
 
 
Q