Требуется ли для URL-адреса установка файлов cookie?Я столкнулся с той же проблемой с отсутствующими файлами cookie.Вы можете проверить, пытаясь открыть URL в инкогнито-окне.Если он по-прежнему воспроизводится нормально, возможно, вы можете отладить его с помощью -
, создав объект AVURLAsset
с URL-адресом, например -
AVURLAsset(url: <URL>, options:[])
и установив для делегата resourceLoader
значение self.Подобно urlAsset?.resourceLoader.setDelegate(self, queue: .main)
и реализуйте функции
func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest) -> Bool {
return true
}
func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForRenewalOfRequestedResource renewalRequest: AVAssetResourceRenewalRequest) -> Bool {
return true
}
func resourceLoader(_ resourceLoader: AVAssetResourceLoader, didCancel loadingRequest: AVAssetResourceLoadingRequest) {
}
func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForResponseTo authenticationChallenge: URLAuthenticationChallenge) -> Bool {
return true
}
func resourceLoader(_ resourceLoader: AVAssetResourceLoader, didCancel authenticationChallenge: URLAuthenticationChallenge) {
}
Но если для этого требуются файлы cookie - установите их в объекте AVURLAsset
, например
let asset = AVURLAsset(url: videoURL, options: ["AVURLAssetHTTPHeaderFieldsKey": ["Cookie": "<YOUR TOKEN>"]])