Fix transparent profile card mp4 rendering

This commit is contained in:
zhx 2026-05-16 02:03:51 +08:00
parent dd4e2cf08c
commit 1542f82dd2
4 changed files with 42 additions and 7 deletions

View File

@ -329,6 +329,8 @@ class _LoopingDataCardVapVideo extends StatefulWidget {
}
class _LoopingDataCardVapVideoState extends State<_LoopingDataCardVapVideo> {
static const int _legacyRgbLeftAlphaRightMode = 3;
VapController? _controller;
int _playToken = 0;
bool _failed = false;
@ -386,6 +388,8 @@ class _LoopingDataCardVapVideoState extends State<_LoopingDataCardVapVideo> {
return;
}
await controller.setMute(true);
await controller.enableVersion1(true);
await controller.setVideoMode(_legacyRgbLeftAlphaRightMode);
await controller.setLoop(widget.loop ? -1 : 0);
await controller.setScaleType(_scaleTypeForFit(widget.fit).key);
if (!_isCurrent(token, controller)) {

View File

@ -258,13 +258,25 @@ class VapView(
result.success(null)
}
"setScaleType" -> {
val type = call.argument<String>("scaleType")
setScaleType(type)
result.success(null)
}
"setVapTagContent" -> {
"setScaleType" -> {
val type = call.argument<String>("scaleType")
setScaleType(type)
result.success(null)
}
"enableVersion1" -> {
val enable = call.argument<Boolean>("enable") ?: false
animView.enableVersion1(enable)
result.success(null)
}
"setVideoMode" -> {
val mode = call.argument<Int>("mode") ?: 1
animView.setVideoMode(mode)
result.success(null)
}
"setVapTagContent" -> {
val tag = call.argument<String>("tag")
val contentMap = call.argument<Map<String, String>>("content")
if (tag != null && contentMap != null) {

View File

@ -67,6 +67,8 @@ public class VapFlutterView: NSObject, FlutterPlatformView {
scaleType = value
}
result(nil)
case "enableVersion1", "setVideoMode":
result(nil)
case "setVapTagContent":
if let args = call.arguments as? [String: Any],
let tag = args["tag"] as? String,

View File

@ -396,6 +396,23 @@ class VapController {
await __channel.invokeMethod('setScaleType', {'scaleType': scaleType});
}
/// Enables compatibility mode for legacy RGB/alpha split MP4 resources
/// that do not contain a VAP config box.
Future<void> enableVersion1(bool enable) async {
await __channel.invokeMethod('enableVersion1', {'enable': enable});
}
/// Sets legacy split MP4 mode.
///
/// Tencent VAP values:
/// - 1: alpha left, RGB right
/// - 2: alpha top, RGB bottom
/// - 3: RGB left, alpha right
/// - 4: RGB top, alpha bottom
Future<void> setVideoMode(int mode) async {
await __channel.invokeMethod('setVideoMode', {'mode': mode});
}
/// Sets content for a specific VAP tag.
///
/// VAP tags are placeholders in the animation file that can be replaced