AliPlayerWidgetData constructor
AliPlayerWidgetData({
- SceneType sceneType = SceneType.vod,
- required VideoSource videoSource,
- AndroidViewType androidViewType = AndroidViewType.defaultValue,
- String coverUrl = "",
- String videoTitle = "",
- String thumbnailUrl = "",
- String externalSubtitleUrl = "",
- bool autoPlay = true,
- String traceId = "",
- int startTime = 0,
- int seekMode = FlutterAvpdef.ACCURATE,
- bool allowedScreenSleep = false,
- bool pauseOnBackground = true,
- bool isHardWareDecode = true,
- SubtitleConfig subtitleConfig = const SubtitleConfig(),
- SubtitleBuilder? subtitleBuilder,
- OnPlayerConfigCallback? onPlayerConfig,
- List<
double> playbackSpeeds = SettingConstants.speedOptions, - Duration autoHideControlsDuration = SettingConstants.defaultAutoHideControlsDuration,
- List<
ChapterInfo> chapters = const [],
构造函数,用于创建 AliPlayerWidgetData 实例。
Constructor to create an instance of AliPlayerWidgetData.
参数:
sceneType:视频场景类型,默认为点播(VOD)。androidViewType:Android 播放器视图类型,默认为 AndroidViewType.defaultValue。coverUrl:视频封面图片地址,默认为空字符串。videoTitle:视频标题,默认为空字符串。thumbnailUrl:视频缩略图地址,默认为空字符串。autoPlay:是否自动播放,默认为 true。traceId:用于跟踪视频播放的 ID,默认为空字符串。startTime:视频起始播放时间(秒),必须为非负数,默认为 0。seekMode:视频跳转模式,默认为精确跳转。allowedScreenSleep:是否允许屏幕休眠,默认为 false(保持屏幕常亮)。pauseOnBackground:是否在进入后台时自动暂停播放,默认为 true(进入后台自动暂停)。isHardWareDecode:是否开启硬解码,默认为true。subtitleConfig:字幕配置,默认为默认配置。subtitleBuilder:字幕构建器,可以为空。onPlayerConfig:播放器自定义配置回调,在 prepare() 前调用,可以为空。playbackSpeeds:自定义可选播放速度列表,默认为 SettingConstants.speedOptions。autoHideControlsDuration:播放控件自动隐藏时间,默认为 SettingConstants.defaultAutoHideControlsDuration。chapters:章节信息列表,默认为空列表。
Parameters:
sceneType: The type of video scene, defaulting to Video On Demand (VOD).- videoSource: Video source object defining the playback source (required).
androidViewType: Android player view type, defaults to AndroidViewType.defaultValue.coverUrl: The URL of the cover image for the video, defaulting to an empty string.videoTitle: The title of the video, defaulting to an empty string.thumbnailUrl: The URL of the thumbnail image for the video, defaulting to an empty string.externalSubtitleUrl: The URL of the external subtitle for the video, defaulting to an empty string.autoPlay: Whether to autoplay the video, defaulting to true.traceId: The ID used to track video playback, defaulting to an empty string.startTime: The start time of video playback in seconds, must be non-negative, defaulting to 0.seekMode: The seek mode for video playback, defaulting to accurate seeking.allowedScreenSleep: Whether to allow screen sleep, default is false (keeps screen awake).pauseOnBackground: Whether to auto-pause on background, default is true (auto-pause on background).isHardWareDecode: Whether to enable hardwareDecoder , default is true.subtitleConfig: Subtitle configuration, default is default configuration.subtitleBuilder: Subtitle builder, can be null.onPlayerConfig: Player custom configuration callback, called before prepare(), can be null.playbackSpeeds: Custom playback speed options, defaults to SettingConstants.speedOptions.autoHideControlsDuration: Duration before controls auto-hide, defaults to SettingConstants.defaultAutoHideControlsDuration.chapters: Chapter info list, defaults to an empty list.
Implementation
AliPlayerWidgetData({
this.sceneType = SceneType.vod,
required this.videoSource,
this.androidViewType = AndroidViewType.defaultValue,
this.coverUrl = "",
this.videoTitle = "",
this.thumbnailUrl = "",
this.externalSubtitleUrl = "",
this.autoPlay = true,
this.traceId = "",
this.startTime = 0,
this.seekMode = FlutterAvpdef.ACCURATE,
this.allowedScreenSleep = false,
this.pauseOnBackground = true,
this.isHardWareDecode = true,
this.subtitleConfig = const SubtitleConfig(),
this.subtitleBuilder,
this.onPlayerConfig,
this.playbackSpeeds = SettingConstants.speedOptions,
this.autoHideControlsDuration =
SettingConstants.defaultAutoHideControlsDuration,
this.chapters = const [],
}) : assert(startTime >= 0, "Start time must be non-negative"),
assert(
playbackSpeeds.isNotEmpty,
'playbackSpeeds must contain at least one value',
),
assert(
playbackSpeeds.every((s) => s > 0),
'All playback speeds must be greater than 0',
),
assert(
autoHideControlsDuration > Duration.zero,
'autoHideControlsDuration must be positive',
);