OnPlayerConfigCallback typedef
OnPlayerConfigCallback =
FutureOr<void> Function(FlutterAliplayer player)
实例级别播放器自定义配置回调
Instance-level player custom configuration callback.
在播放器 prepare() 之前调用,允许用户对播放器实例进行自定义配置, 例如 setConfig(设置缓冲、refer 等)、setOption 等。 支持异步操作(如 getConfig/setConfig),Widget 会等待回调完成后再执行 prepare()。
适用于实例级别的播放器配置,与全局级别的 OnGlobalInitCallback 互补:
- 实例配置 → 使用 OnPlayerConfigCallback,通过 AliPlayerWidgetData.onPlayerConfig 注入
- 全局配置 → 使用 OnGlobalInitCallback,通过 AliPlayerWidgetGlobalSetting.setOnGlobalInit 注册
Called before player prepare(), allowing users to customize the player instance, such as setConfig (buffer, referer, etc.), setOption, etc. Supports async operations (e.g., getConfig/setConfig). The Widget will await the callback completion before calling prepare().
This callback is designed for instance-level player configuration and complements the global-level OnGlobalInitCallback:
- Instance config → Use OnPlayerConfigCallback via AliPlayerWidgetData.onPlayerConfig
- Global config → Use OnGlobalInitCallback via AliPlayerWidgetGlobalSetting.setOnGlobalInit
Implementation
typedef OnPlayerConfigCallback = FutureOr<void> Function(
FlutterAliplayer player,
);