"AVQueuePlayer" has gaps when playing local music on iOS 17 real device.

I've been using the init(items: [AVPlayerItem]) method of AVQueuePlayer to play local music, and it has been working well from iOS 14 to iOS 16 without any playback gaps. However, I just upgraded my iPhone 12 to iOS 17, and there are gaps when playing music. I also tested it on an iPhone 15 Pro, and it has the same issue. Interestingly, there is no such problem when running it on the iOS 17 simulator.

This is the code.

//  ViewController.swift
//  AVQueueDemo
//
//  Created by dingronghui on 2023/9/26.
//

import UIKit
import AVFoundation
class ViewController: UIViewController {

    var queuePlayer:AVQueuePlayer?
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        let audioFileURLs = [
            Bundle.main.url(forResource: "song1", withExtension: "mp3")!,
            Bundle.main.url(forResource: "song2", withExtension: "mp3")!,
            Bundle.main.url(forResource: "song3", withExtension: "mp3")!,
            Bundle.main.url(forResource: "song3", withExtension: "mp3")!,
            Bundle.main.url(forResource: "song4", withExtension: "mp3")!,
            Bundle.main.url(forResource: "song4", withExtension: "mp3")!,
            Bundle.main.url(forResource: "song4", withExtension: "mp3")!,
            Bundle.main.url(forResource: "song4", withExtension: "mp3")!,
            Bundle.main.url(forResource: "song4", withExtension: "mp3")!,
        ]

        var playerItems: [AVPlayerItem] = []

        for fileURL in audioFileURLs {
            let playerItem = AVPlayerItem(url: fileURL)
            playerItems.append(playerItem)
        }

        queuePlayer = AVQueuePlayer(items: playerItems)

        queuePlayer?.play()
        print("play")
    }


}

"AVQueuePlayer" has gaps when playing local music on iOS 17 real device.
 
 
Q