Linsey
Linsey

Reputation: 13

Deezer playback stops when I activate the lock screen

We are currently integrating the Deezer iOS SDK into our podcast player app.

We’re playing albums (DZRAlbum) via DZRPlayer, and playback works fine within the app and when the app is in the background without locking the screen. However once we activate the lock screen, the track continues playing for around 10-30 seconds, and then stops.

We’ve also integrated Spotify and Apple Music into our app, and both of these continue playing when we lock the screen.

To keep our audio active in the background, we’re currently doing the following:

1 - We’ve marked our app as playing audio in the background in the app Capabilities

Capabilities -> Background modes -> 'Audio, AirPlay and Picture in Picture' is checked

2 - We’re using an AVAudioSession to mark when we start/stop playing audio, using:

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];

and

[[AVAudioSession sharedInstance] setActive:NO error:nil];

3 - We’re starting a background task in our appDelegate when the app goes into the background:

- (void)applicationDidEnterBackground:(UIApplication *)application {
    UIBackgroundTaskIdentifier bgTask = 0;
    UIApplication  *app = [UIApplication sharedApplication];
    bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
        [app endBackgroundTask:bgTask];
    }];
}

Since background and lock screen playback works without interruption for Spotify (via the Spotify iOS SDK) and Apple Music playback (via MPMusicPlayerController.applicationMusicPlayer), I'm not sure what could be causing the interruption with Deezer.

Any thoughts?

This was tested on iOS 11 and iOS 12.

Upvotes: 1

Views: 621

Answers (0)

Related Questions