mohe_native_player
A Flutter native video player plugin for iOS and Android with full-featured controls, HLS/DASH support, danmaku (barrage), DLNA casting, Picture-in-Picture, and more.
Features
- Native playback - Uses platform-native players (AVPlayer on iOS, ExoPlayer on Android)
- HLS & DASH - Supports m3u8, mpd streaming formats
- Full controls - Play, pause, seek, volume, brightness, playback speed
- Danmaku/Barrage - Built-in danmaku overlay support
- DLNA casting - Cast video to DLNA devices
- Picture-in-Picture - PiP mode on supported devices
- Fullscreen - Portrait and landscape fullscreen with orientation lock
- Episode selector - Built-in episode list UI
- Quality selector - Multi-quality HLS switching
- Custom UI - Customizable progress bar, buttons, loading GIF, toast
Platform Support
| Platform | Support |
|---|---|
| iOS | ✅ |
| Android | ✅ |
Installation
Add to your pubspec.yaml:
dependencies:
mohe_native_player: ^1.11.5
Then run:
flutter pub get
Usage
import 'package:mohe_native_player/mohe_native_player.dart';
// Create a controller
final controller = PlayerController();
// Build the player view
PlayerView(controller: controller)
// After the view is created, play a video
await controller.play('https://example.com/video.m3u8');
// Listen to events
controller.eventStream.listen((event) {
print('Event: ${event.event} ${event.params}');
});
// Control playback
await controller.pause();
await controller.resume();
await controller.seek(30.0); // Seek to 30 seconds
await controller.setRate(1.5); // 1.5x speed
await controller.enterFullscreen();
API Overview
PlayerController
- Playback:
play(),pause(),resume(),stop(),seek() - Info:
getCurrentTime(),getDuration(),getCurrentVideoDisplayInfo(),getVolume(),getBrightness() - Settings:
setRate(),setVolume(),setMuted(),setBrightness() - Load failure:
setLoadFailureDetection()— detect load/stall timeout and surface anerrorevent with areason(seePlayerLoadFailureReason) so you can show a "load failed / retry" UI - Fullscreen:
enterFullscreen(),exitFullscreen(),lockOrientation() - Danmaku:
addBarrageText(),setBarrageVisible(),clearBarrage() - PiP:
enterPIP(),exitPIP() - DLNA:
startDLNADiscovery(),connectDLNADevice(),dlnaPlay(), etc. - UI:
setPlayerTitle(),setProgressSliderColor(),showEpisodeSelector(), etc.
PlayerView
A widget that renders the native video player. Pass a PlayerController to control playback and receive events.
License
MIT
Libraries
- mohe_native_player
- mohe_native_player - Flutter video player plugin for iOS and Android.
- player_plugin
- player_plugin.dart Dart API for the native video player (iOS + Android).
- ui/fullscreen_page
- fullscreen_page.dart FullscreenPlayerPage — landscape fullscreen overlay page.
- ui/gesture_layer
- gesture_layer.dart GestureLayer — Flutter gesture handler overlay for the native player view.
- ui/mobile_overlay
- mobile_overlay.dart MobileOverlay — Flutter control layer displayed on top of the native PlatformView. Supports portrait (isFullscreen=false) and landscape (isFullscreen=true) layouts, matching the native iOS PlayerUIManager.
- ui/player_state
- player_state.dart PlayerUIState — ChangeNotifier that mirrors native player events into observable Dart properties for overlay/control widgets.
- ui/player_view_with_controls
- player_view_with_controls.dart PlayerViewWithControls — Stack of the native PlatformView + Flutter overlay.
- ui/progress_bar
- progress_bar.dart Custom video progress bar that precisely mirrors the native iOS player style.