hls_proplayer 0.1.5
hls_proplayer: ^0.1.5 copied to clipboard
A customizable Flutter video player with HLS support, quality selection, playback speed control, autoplay, looping, and fullscreen handling for live and recorded streams.
hls_proplayer #
A fully customizable Flutter video player for HLS (.m3u8) live and recorded streams, with video quality switching, custom controls, playback speed, fullscreen handling, and offline MP4 playback with zoom support. π₯
β¨ Features #
- π‘ Play HLS live and recorded streams
- ποΈ Video quality switching (parse
.m3u8variants) - π§© Fully customizable UI: theming + builders for controls, placeholder, buffering
- π Token auth via request headers
- β―οΈ Autoplay and looping options
- β© Playback speed control
- π± Fullscreen orientation handling
- π₯ Offline download support β play saved
.mp4files - π Zoom & pan gestures when playing videos
π Installation #
Add to your pubspec.yaml:
dependencies:
hls_proplayer: ^0.1.5
---
## π§° Usage
### Basic Example
```dart
import 'package:flutter/material.dart';
import 'package:hls_proplayer/hls_proplayer.dart';
class VideoPlayerScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: HlsPlayer(
url: 'https://example.com/master.m3u8',
mode: Mode.live,
autoplay: true,
looping: false,
),
);
}
}
Advanced Example with Custom Theme #
HlsPlayer(
url: 'https://example.com/master.m3u8',
mode: Mode.live,
headers: {'x-token': 'your-auth-token'},
autoplay: true,
looping: false,
startAt: 0, // Start position in seconds (for recorded mode)
controlsHideTimeout: const Duration(seconds: 4),
controlsTheme: const HlsControlsTheme(
progressActiveColor: Colors.blue,
progressInactiveColor: Colors.grey,
liveIndicatorColor: Colors.red,
iconColor: Colors.white,
iconSize: 24.0,
),
placeholderBuilder: (ctx) => const Center(
child: Text('Loading video...', style: TextStyle(color: Colors.white)),
),
bufferingIndicatorBuilder: (ctx) => const Center(
child: CircularProgressIndicator(color: Colors.blue),
),
)
Recorded Video Playback #
HlsPlayer(
url: 'https://example.com/recorded.m3u8',
mode: Mode.recorded,
startAt: 30, // Start at 30 seconds
autoplay: true,
looping: true,
)
MP4 File Playback #
HlsPlayer(
url: '/path/to/local/video.mp4',
mode: Mode.MP4,
autoplay: true,
looping: false,
)
Custom Controls #
HlsPlayer(
url: 'https://example.com/master.m3u8',
mode: Mode.live,
controlsBuilder: (context, controller, isFullScreen, qualities, controlsVisible, showControls) {
return MyCustomControls(
controller: controller,
isFullScreen: isFullScreen,
qualities: qualities,
onToggleControls: showControls,
);
},
)
π¨ Customization API #
- Theming: pass
HlsControlsThemeto style overlay, icon colors/sizes, progress & live colors. - Controls builder: provide
controlsBuilderto render a completely custom controls widget. - Placeholders:
placeholderBuilder(before qualities load) andbufferingIndicatorBuilder(while loading/buffering). - Behavior:
autoplay,looping,controlsHideTimeout.
π¦ Example App #
See example/ for a minimal app demonstrating live and recorded playback and custom UI.
β Troubleshooting #
- UnimplementedError: init() has not been implemented. Add
video_playeras a dependency in your app (not only the plugin) so the platform implementation is registered:
dependencies:
video_player: ^2.10.0
- Android: ensure a recent emulator/device with GLES 2.0+. If you see
called unimplemented OpenGL ES API, try a real device or change emulator graphics settings.