AVPlayer not switching to next track when screen is lock

I am using AVPlayer to stream audio, the audio is playing and it goes to the next track when the app is in the background and the screen is locked. My issue is that whenever the screen goes black and the current track finishes playing, the next track will not play unless I wake the screen then it skips to the next track. I also setup remote controls and that's working correctly. Any help would be appreciated, thanks in advance...

This is how I am skipping to next track

NotificationCenter.default.addObserver(self, selector: #selector(audioFinishPlaying), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: AVPlayerManager.instance.player.currentItem)

@objc func audioFinishPlaying(notification: NotificationCenter) {

    if repeatSelected == true {
        AVPlayerManager.instance.player.seek(to: kCMTimeZero)
        AVPlayerManager.instance.player.play()
    }

    else {

        let current = focusedAudioItem
        if current + 1 < subCategoryItems.count {
            let path  = IndexPath(item: current + 1, section: 0)
            self.collectionView.selectItem(at: path, animated: true, scrollPosition: .centeredHorizontally)
    }
        else {

            playBtn.setImage(#imageLiteral(resourceName: "play"), for: UIControlState.normal)
            AVPlayerManager.instance.player.seek(to: kCMTimeZero)
        }
   }

}

Audio Session

func setupAudioSession() {

    let audioSession = AVAudioSession.sharedInstance()

    do {
        try audioSession.setCategory(AVAudioSessionCategoryPlayback)
        UIApplication.shared.beginReceivingRemoteControlEvents()
        try audioSession.setActive(true)

    } catch {

        print(error.localizedDescription)
    }
 }