AliPlayerWidgetData constructor
AliPlayerWidgetData({
- SceneType sceneType = SceneType.vod,
- VideoSource? videoSource,
- @Deprecated('Use videoSource or AliPlayerWidgetData.fromUrl() instead.') String videoUrl = "",
- String coverUrl = "",
- String videoTitle = "",
- String thumbnailUrl = "",
- bool autoPlay = true,
- int startTime = 0,
- int seekMode = FlutterAvpdef.ACCURATE,
- bool allowedScreenSleep = false,
- bool isHardWareDecode = true,
构造函数,用于创建 AliPlayerWidgetData 实例。
Constructor to create an instance of AliPlayerWidgetData.
参数:
sceneType
:视频场景类型,默认为点播(VOD)。videoUrl
:视频播放地址,已过时,建议使用 videoSource 代替。coverUrl
:视频封面图片地址,默认为空字符串。videoTitle
:视频标题,默认为空字符串。thumbnailUrl
:视频缩略图地址,默认为空字符串。autoPlay
:是否自动播放,默认为 true。startTime
:视频起始播放时间(秒),必须为非负数,默认为 0。seekMode
:视频跳转模式,默认为精确跳转。allowedScreenSleep
:是否允许屏幕休眠,默认为 false。isHardWareDecode
:是否开启硬解码,默认为true。
Parameters:
sceneType
: The type of video scene, defaulting to Video On Demand (VOD).- videoSource: Video source object defining the playback source (recommended).
videoUrl
: The URL of the video to be played, deprecated, use videoSource instead.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.autoPlay
: Whether to autoplay the video, defaulting to true.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.isHardWareDecode
: Whether to enable hardwareDecoder , default is true.
Implementation
AliPlayerWidgetData({
this.sceneType = SceneType.vod,
VideoSource? videoSource,
@Deprecated('Use videoSource or AliPlayerWidgetData.fromUrl() instead.')
String videoUrl = "", // 标记参数为过时
this.coverUrl = "",
this.videoTitle = "",
this.thumbnailUrl = "",
this.autoPlay = true,
this.startTime = 0,
this.seekMode = FlutterAvpdef.ACCURATE,
this.allowedScreenSleep = false,
this.isHardWareDecode = true,
}) : assert(startTime >= 0, "Start time must be non-negative") {
// 初始化 videoSource:
// 1. 如果提供了 videoSource,则直接使用
// 2. 如果提供了 videoUrl,则创建 URL 类型的 videoSource
// 3. 如果两者都没提供,则抛出异常
if (videoSource != null) {
this.videoSource = videoSource;
} else if (videoUrl.isNotEmpty) {
this.videoSource = VideoSourceFactory.createUrlSource(videoUrl);
} else {
throw ArgumentError("Either videoSource or videoUrl must be provided");
}
}