Post

Replies

Boosts

Views

Activity

Reply to AVPlayer not playing m3u8 from local file
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
Jun ’24
Reply to AVPlayer getting CoreMediaErrorDomain error -12865 error
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
Jun ’24
Reply to CoreMediaErrorDomain error -12865
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
Jun ’24