# 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`:

```yaml
dependencies:
  mohe_native_player: ^1.0.1
```

Then run:

```bash
flutter pub get
```

## Usage

```dart
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()`, `getVolume()`, `getBrightness()`
- **Settings**: `setRate()`, `setVolume()`, `setMuted()`, `setBrightness()`
- **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
