Flutter short drama HLS integration
ShortDramaAPI returns HLS (.m3u8) playback URLs. Flutter apps can play those streams with standard video packages. This guide does not assume a vendor SDK.
SDK clarity: Flutter can play HLS with packages such as
video_player. That is not the same as a vendor-maintained ShortDramaAPI Flutter SDK. This guide does not assume a vendor SDK.
Flow
- Your Dart app calls your backend for series / episode lists.
- Your backend uses the ShortDramaAPI key to call catalog → episodes → playback.
- Your backend returns the HLS URL (and optional subtitle URLs) to Flutter.
- Initialize a video controller with that URL inside a 9:16 player widget.
video_player example
Fetch a fresh playback URL from your backend if it expires, then initialize the controller:
import 'package:video_player/video_player.dart';
late final VideoPlayerController controller;
Future<void> playHls(String playbackUrl) async {
controller = VideoPlayerController.networkUrl(
Uri.parse(playbackUrl),
formatHint: VideoFormat.hls,
);
await controller.initialize();
await controller.play();
}
If playback fails after a while, request a fresh URL from your backend rather than reusing an expired CDN link.
Player options (high level)
- Packages that wrap AVPlayer / ExoPlayer typically support HLS on iOS and Android.
- Prefer packages that expose audio and subtitle track selection so you can mirror the separate selectors in our web demo.
- Handle expired playback URLs by re-fetching playback from your backend, not by hard-coding CDN links.
Vertical UX tips
- Lock the player viewport to 9:16 for short-drama feeds.
- Start muted only when required for autoplay policies; always provide visible controls.
- Respect
prefers-reduced-motion/ accessibility settings where the OS exposes them.