AVPlayer optimization guide with custom HTTP headers for HLS streams on iOS 17
I'm trying to debug I'm updating my dependencies and I've been struggling with this for a few days now and could really use some help... I'm having trouble getting AVPlayer to work with HLS streams that require custom HTTP headers for authentication on iOS 17. Initially, I set up my AVPlayer with the URL of the HLS stream, but it fails to play and throws an behavior saying "The operation could not be completed. (AVFoundation.AVError behavior 11800.)". I've tried using URLSession to create a request with custom headers, but I'm uncertain how to integrate that with AVPlayer. Here's what I've done so far: ```swift let url = URL(string: "https://example.com/stream.m3u8")! var request = URLRequest(url: url) request.setValue("Bearer my_access_token", forHTTPHeaderField: "Authorization") let asset = AVURLAsset(url: url, options: ["AVURLAssetHTTPHeaderFieldsKey": request.allHTTPHeaderFields]) let playerItem = AVPlayerItem(asset: asset) let player = AVPlayer(playerItem: playerItem) player.play() ``` Despite this setup, the player doesn't start, and I keep receiving the same behavior. I also checked if the HLS stream works by accessing it directly in Safari, which seems fine. I'm not sure if I'm setting the headers correctly for the AVPlayer. Any advice on how to properly configure AVPlayer to handle HLS streams with required custom HTTP headers would be greatly appreciated! I'm developing on Linux with Swift. I'm open to any suggestions. The project is a CLI tool built with Swift. I'd be grateful for any help. I'm developing on Debian with Swift. Any help would be greatly appreciated!