diff --git a/README.zh.md b/README.zh.md index 7964ff9..5bc0bf8 100644 --- a/README.zh.md +++ b/README.zh.md @@ -81,6 +81,9 @@ class MyApp extends StatelessWidget { child: FlutterVapView( controller: vapController, scaleType: VapScaleType.fitXY, + onCreateView: () { + // 现在可以在这里播放 + }, onVideoStart: () { debugPrint('VAP - 视频开始播放'); }, diff --git a/lib/flutter_vap_view.dart b/lib/flutter_vap_view.dart index c279646..5188640 100644 --- a/lib/flutter_vap_view.dart +++ b/lib/flutter_vap_view.dart @@ -1,4 +1,5 @@ import 'dart:io'; +import 'dart:nativewrappers/_internal/vm/lib/ffi_allocation_patch.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -19,6 +20,7 @@ class FlutterVapView extends StatefulWidget { this.onVideoRender, this.onFailed, this.scaleType = VapScaleType.fitXY, + this.onCreateView, }); /// 外部控制器,必填 @@ -43,6 +45,9 @@ class FlutterVapView extends StatefulWidget { /// Video scaling type, default is fitXY final VapScaleType scaleType; + // 用于PlatformView创建完成后的回调 + final VoidCallback? onCreateView; + @override State createState() => _FlutterVapViewState(); } @@ -60,6 +65,7 @@ class _FlutterVapViewState extends State { _channel = MethodChannel('flutter_vap_plugin_$id'); _channel?.setMethodCallHandler(_handleMethodCall); widget.controller.bindChannel(_channel!); + widget.onCreateView.call(); } Future _handleMethodCall(MethodCall call) async {