I'm trying to make a request to my server through AVPlayer
with additional header parameters. The server returns an .mp3
file and a record is inserted in the DB for history preview purposes. However, the DB record is doubled, with a time difference of less than 1s.
let headers: [String:String] = [
"track_id" : "\(songid)",
"type" : "\(songtype)",
"user_id" : MyAccount.shared.id,
"token" : MyAccount.shared.apiToken,
]
let item = AVPlayerItem(asset: AVURLAsset(url: MusicPlayer.url, options: [
"AVURLAssetHTTPHeaderFieldsKey":headers
]))
// this is a queue player
player.insert(item, after: nil)
player.play()
Both iOS 9.2 and 10.3 show the same results.