configure method
配置播放控制器
Configure the player controller with the given data.
data
The configuration data for the player, including video URL and other settings.
Implementation
void configure(AliPlayerWidgetData data) {
logi("[api][configure]: $data");
_widgetData = data;
// 可选:推荐使用`播放器单点追查`功能,当使用阿里云播放器 SDK 播放视频发生异常时,可借助单点追查功能针对具体某个用户或某次播放会话的异常播放行为进行全链路追踪,以便您能快速诊断问题原因,可有效改善播放体验治理效率。
// traceId 值由您自行定义,需为您的用户或用户设备的唯一标识符,例如传入您业务的 userid 或者 IMEI、IDFA 等您业务用户的设备 ID。
// 传入 traceId 后,埋点日志上报功能开启,后续可以使用播放质量监控、单点追查和视频播放统计功能。
// 文档:https://help.aliyun.com/zh/vod/developer-reference/single-point-tracing
if (_widgetData?.traceId.isNotEmpty ?? false) {
_aliPlayer.setTraceID(_widgetData!.traceId);
}
// 配置预渲染
_configureAllowPreRender();
// 配置播放源
_configurePlayerSource(data);
_aliPlayer.setEnableHardwareDecoder(data.isHardWareDecode);
_aliPlayer.setStartTime(data.startTime, data.seekMode);
_aliPlayer.setAutoPlay(data.autoPlay);
// 准备播放
prepare();
// 允许屏幕常亮
if (_widgetData?.allowedScreenSleep == true) {
WakelockPlus.enable();
}
}