fix(player): refresh Android MPV decoder on startup
This commit is contained in:
@@ -693,13 +693,20 @@ class MpvPlayerCore(private val activity: Activity) : SurfaceHolder.Callback {
|
||||
p.observeProperty(name, fmt)
|
||||
}
|
||||
|
||||
fun command(args: Array<String>) {
|
||||
if (!isInitialized || disposing || args.isEmpty()) return
|
||||
fun command(args: Array<String>, onComplete: ((Boolean) -> Unit)? = null) {
|
||||
if (!isInitialized || disposing || args.isEmpty() || !scope.isActive) {
|
||||
onComplete?.invoke(false)
|
||||
return
|
||||
}
|
||||
scope.launch {
|
||||
var success = false
|
||||
try {
|
||||
player?.command(*args)
|
||||
success = true
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "command failed", e)
|
||||
} finally {
|
||||
onComplete?.invoke(success)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,8 +271,14 @@ class MpvPlayerPlugin :
|
||||
return
|
||||
}
|
||||
|
||||
playerCore?.command(args.toTypedArray())
|
||||
result.success(null)
|
||||
val core = playerCore
|
||||
if (core == null) {
|
||||
result.success(null)
|
||||
return
|
||||
}
|
||||
core.command(args.toTypedArray()) {
|
||||
result.success(null)
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleSetVisible(call: MethodCall, result: MethodChannel.Result) {
|
||||
|
||||
Reference in New Issue
Block a user