fix: show file diagnostics (exists, size, magic bytes) directly on error screen
This commit is contained in:
parent
0e172e015e
commit
6503712be9
@ -255,6 +255,9 @@ final class PlayerBridge: ObservableObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 播放器报错的诊断消息(存在这里,和错误一起显示)
|
||||||
|
private var lastDiagMsg = ""
|
||||||
|
|
||||||
func playIndex(_ index: Int) {
|
func playIndex(_ index: Int) {
|
||||||
guard index >= 0 && index < queue.count else { return }
|
guard index >= 0 && index < queue.count else { return }
|
||||||
|
|
||||||
@ -280,6 +283,7 @@ final class PlayerBridge: ObservableObject {
|
|||||||
try? fh.close()
|
try? fh.close()
|
||||||
}
|
}
|
||||||
diagLog("Local file check: exists=\(exists) readable=\(readable) size=\(fileSize) magic=\(String(format:"%08X", magic))")
|
diagLog("Local file check: exists=\(exists) readable=\(readable) size=\(fileSize) magic=\(String(format:"%08X", magic))")
|
||||||
|
lastDiagMsg = "file: exists=\(exists) readable=\(readable)\nsize=\(fileSize) magic=\(String(format:"%08X", magic))"
|
||||||
}
|
}
|
||||||
|
|
||||||
// 先清除旧的 KVO,避免野指针
|
// 先清除旧的 KVO,避免野指针
|
||||||
@ -358,7 +362,7 @@ final class PlayerBridge: ObservableObject {
|
|||||||
let errMsg = err?.localizedDescription ?? "Unknown error"
|
let errMsg = err?.localizedDescription ?? "Unknown error"
|
||||||
let errCode = (err as NSError?)?.code ?? 0
|
let errCode = (err as NSError?)?.code ?? 0
|
||||||
let errDomain = (err as NSError?)?.domain ?? "none"
|
let errDomain = (err as NSError?)?.domain ?? "none"
|
||||||
let fullMsg = "\(errMsg)\n[code:\(errCode) domain:\(errDomain)]\n\(item.url.lastPathComponent)"
|
let fullMsg = "\(errMsg)\n[code:\(errCode) domain:\(errDomain)]\n\(self?.lastDiagMsg ?? "")\n\(item.url.lastPathComponent)"
|
||||||
self?.diagLog("AVPlayerItem FAILED: \(errMsg) code=\(errCode) domain=\(errDomain)")
|
self?.diagLog("AVPlayerItem FAILED: \(errMsg) code=\(errCode) domain=\(errDomain)")
|
||||||
self?.playerStatus = .error(fullMsg)
|
self?.playerStatus = .error(fullMsg)
|
||||||
self?.loadingTimer?.invalidate()
|
self?.loadingTimer?.invalidate()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user