AVPlayer getting CoreMediaErrorDomain error -12865 error

Hello,

I use AVPlayer to play locally recorded media on my iPhone.

I encounter this error when loading the media (when I read the playerItem.observe event, I have a .failed with this :

The operation couldn’t be completed. (CoreMediaErrorDomain error -12865.)

I did not find any explanation about this specific error in the documentation. Does anyone have any information about this specific error? This error seems totally random.

Thanks in advance,

I had the same problem. I was because I used the url received in param willDownloadTo of function:

urlSession(_:aggregateAssetDownloadTask:willDownloadTo:)

I always received the error -12865

To solve it when download finished in function : urlSession(_:task:didCompleteWithError:)

I create un bookmarkData with the previous mentioned url, and store it in User defaults with an unique identifier for de asset:

 let userDefaults = UserDefaults.standard
 let bookmark = try downloadURL.bookmarkData()
 userDefaults.set(bookmark, forKey: AssetIdentifier)

With this, when I need the url to playback a recover it from user defaults:

func localAssetFor(withID identifier: String) -> AVURLAsset? { let userDefaults = UserDefaults.standard guard let localFileLocation = userDefaults.value(forKey: identifier) as? Data else { return nil } var asset: AVURLAsset? var bookmarkDataIsStale = false do { let url = try URL(resolvingBookmarkData: localFileLocation, bookmarkDataIsStale: &bookmarkDataIsStale) if bookmarkDataIsStale { fatalError("Bookmark data is stale!") }

    let urlAsset = AVURLAsset(url: url)
    return urlAsset
} catch {
    fatalError("Failed to create URL from bookmark with error: \(error)")
}

}

With this changes I always have to playback offline content without error 12865. Hope this help Pedro

AVPlayer getting CoreMediaErrorDomain error -12865 error
 
 
Q