A video source is a fundamental data module in AliPlayerKit. It defines multiple video source types and supports three playback methods: VidAuth, VidSts, and URL. This enables unified configuration and management of video resources.
Supported video source types
VidAuth mode (recommended)
This mode authorizes playback using a video ID and a playAuth. Use this mode for scenarios that require a simple authorization mechanism.
// Example: Create playback data with VidAuth
final videoSource = VideoSourceFactory.createVidAuthSource(
vid: "<your-video-id>",
playAuth: "<your-play-auth>",
);
final data = AliPlayerWidgetData(
videoSource: videoSource,
);VidSts mode
This mode uses a video ID (VID) and an Alibaba Cloud STS (Security Token Service) token for playback, providing enhanced security and access control.
// Example: Create playback data with VidSts
final videoSource = VideoSourceFactory.createVidStsSource(
vid: "<your-video-id>",
accessKeyId: "<your-access-key-id>",
accessKeySecret: "<your-access-key-secret>",
securityToken: "<your-security-token>",
region: "<your-region>",
);
final data = AliPlayerWidgetData(
videoSource: videoSource,
);URL mode
This mode plays a video directly from a provided URL. Use this mode for publicly accessible video resources.
// Example: Create playback data with a URL
final videoSource = VideoSourceFactory.createUrlSource(
"<your-video-url>",
);
final data = AliPlayerWidgetData(
videoSource: videoSource,
);Usage
When configuring the player, set the video source using the videoSource property of AliPlayerWidgetData:
// 1. Create a video source for the player.
final videoSource = VideoSourceFactory.createVidAuthSource(
vid: "<your-video-id>",
playAuth: "<your-play-auth>",
);
// 2. Configure the data for the player widget.
final data = AliPlayerWidgetData(
videoSource: videoSource,
videoTitle: "<your-video-title>",
);
// 3. Initialize the player widget controller.
_controller = AliPlayerWidgetController();
_controller.configure(data);Notes
Select the video source type that best fits your business scenario and requirements.
The
VidAuthandVidStsmodes provide higher security and are recommended for scenarios that require authorization.The
URLmode is simple to use and well-suited for public resources, but it offers less security.