mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-29 17:49:03 +03:00
fix playing local anime source videos
This commit is contained in:
parent
e60bd4d07d
commit
faa5e0b403
1 changed files with 6 additions and 13 deletions
|
@ -726,8 +726,7 @@ class PlayerActivity :
|
|||
}
|
||||
subTracks = arrayOf(Track("nothing", "Off")) + it.subtitleTracks.toTypedArray()
|
||||
audioTracks = arrayOf(Track("nothing", "Off")) + it.audioTracks.toTypedArray()
|
||||
val videoUrlString = resolveUri(Uri.parse(it.videoUrl))
|
||||
MPVLib.command(arrayOf("loadfile", videoUrlString))
|
||||
MPVLib.command(arrayOf("loadfile", parseVideoUrl(it.videoUrl)))
|
||||
}
|
||||
launchUI { refreshUi() }
|
||||
}
|
||||
|
@ -962,24 +961,18 @@ class PlayerActivity :
|
|||
setViewMode()
|
||||
subTracks = arrayOf(Track("nothing", "Off")) + it.subtitleTracks.toTypedArray()
|
||||
audioTracks = arrayOf(Track("nothing", "Off")) + it.audioTracks.toTypedArray()
|
||||
val videoUrlString = resolveUri(Uri.parse(it.videoUrl))
|
||||
MPVLib.command(arrayOf("loadfile", videoUrlString))
|
||||
MPVLib.command(arrayOf("loadfile", parseVideoUrl(it.videoUrl)))
|
||||
}
|
||||
launchUI { refreshUi() }
|
||||
}
|
||||
|
||||
private fun resolveUri(data: Uri): String {
|
||||
val filepath = when (data.scheme) {
|
||||
"file" -> data.path
|
||||
"content" -> openContentFd(data)
|
||||
"http", "https", "rtmp", "rtmps", "rtp", "rtsp", "mms", "mmst", "mmsh", "tcp", "udp",
|
||||
-> data.toString()
|
||||
else -> null
|
||||
}
|
||||
return filepath ?: return ""
|
||||
private fun parseVideoUrl(videoUrl: String?): String? {
|
||||
val uri = Uri.parse(videoUrl)
|
||||
return openContentFd(uri) ?: videoUrl
|
||||
}
|
||||
|
||||
private fun openContentFd(uri: Uri): String? {
|
||||
if (uri.scheme != "content") return null
|
||||
val resolver = applicationContext.contentResolver
|
||||
logcat { "Resolving content URI: $uri" }
|
||||
val fd = try {
|
||||
|
|
Loading…
Reference in a new issue