解决录制结束后,无法重新预览相机问题

This commit is contained in:
2026-06-05 15:10:03 +08:00
parent a39fcdb929
commit 016aad49b7
2 changed files with 49 additions and 12 deletions

View File

@@ -161,22 +161,31 @@ class RecordingPlatformHandler(
controller.stopRecording { path ->
RecordingSession.stopForeground(activity)
DoNotDisturbHelper.disable(activity)
mainHandler.post {
val gallerySaved = path != null && controller.status.state != RecordingState.ERROR
val payload =
mutableMapOf<String, Any?>(
"outputPath" to path,
"status" to controller.status.toMap(),
"gallerySaved" to gallerySaved,
)
if (!gallerySaved) {
payload["galleryErrorMessage"] = controller.status.message ?: "保存到相册失败"
}
result.success(payload)
val previewView = activity.recordingPreviewView
if (previewView == null) {
mainHandler.post { deliverStopResult(result, path) }
return@stopRecording
}
controller.rebindForRecording(activity, previewView) { _ ->
mainHandler.post { deliverStopResult(result, path) }
}
}
}
private fun deliverStopResult(result: MethodChannel.Result, path: String?) {
val gallerySaved = path != null && controller.status.state != RecordingState.ERROR
val payload =
mutableMapOf<String, Any?>(
"outputPath" to path,
"status" to controller.status.toMap(),
"gallerySaved" to gallerySaved,
)
if (!gallerySaved) {
payload["galleryErrorMessage"] = controller.status.message ?: "保存到相册失败"
}
result.success(payload)
}
private fun setImmersiveMode(enabled: Boolean) {
val window = activity.window
WindowCompat.setDecorFitsSystemWindows(window, !enabled)