sukov / CachingPlayerItem

An AVPlayerItem subclass that lets you stream and cache media content on iOS
MIT License
75 stars 19 forks source link

Chaching player item failed downloading: Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." #15

Closed rmellmer closed 2 months ago

rmellmer commented 2 months ago

Seeing the following error when using running like:

playerItem = CachingPlayerItem(url: url!, saveFilePath: savePath!, customFileExtension: codec)

The item does actually play fine, just downloading fails with error:

Chaching player item failed downloading: Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={NSLocalizedDescription=The network connection was lost., NSErrorFailingURLStringKey=<redacted>, NSErrorFailingURLKey=<redacted>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <C1AB2C67-D01C-4220-94DE-0F9B3C01EEF7>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <C1AB2C67-D01C-4220-94DE-0F9B3C01EEF7>.<1>, NSUnderlyingError=0x301e54660 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={NSErrorPeerAddressKey=<CFData 0x3033a59f0 [0x1fc933c70]>{length = 16, capacity = 16, bytes = 0x100201bbc0a832640000000000000000}}}}

Struggling to figure out how do diagnose further, I don't think there's actually any network issues going on because the item plays fine. Thanks!

sukov commented 2 months ago

The issue seems to be very likely unrelated to the library. Please try to use something like URLSession.shared.dataTask(with: URLRequest(url: url), completionHandler: { _, _, error in to further debug your error.