flex_video_player 0.1.2 copy "flex_video_player: ^0.1.2" to clipboard
flex_video_player: ^0.1.2 copied to clipboard

A flexible, production-ready Flutter video player package supporting MP4, HLS, reels, quality switching, subtitles, and more. Works on Android, iOS, macOS, and Web.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'screens/asset_example_screen.dart';
import 'screens/custom_controls_screen.dart';
import 'screens/file_example_screen.dart';
import 'screens/hls_example_screen.dart';
import 'screens/mp4_example_screen.dart';
import 'screens/protection_example_screen.dart';
import 'screens/quality_example_screen.dart';
import 'screens/reels_example_screen.dart';
import 'screens/retry_example_screen.dart';
import 'screens/subtitles_example_screen.dart';
import 'screens/tracking_example_screen.dart';
import 'screens/wakelock_example_screen.dart';

void main() {
  runApp(const ExampleApp());
}

class ExampleApp extends StatelessWidget {
  const ExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'flex_video_player Example',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const HomeScreen(),
    );
  }
}

class HomeScreen extends StatelessWidget {
  const HomeScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('flex_video_player Examples'),
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
      ),
      body: ListView(
        children: [
          _ExampleTile(
            icon: Icons.video_file,
            title: 'MP4 / Network',
            subtitle: 'Play a direct MP4 URL',
            onTap: () => _push(context, const Mp4ExampleScreen()),
          ),
          _ExampleTile(
            icon: Icons.stream,
            title: 'HLS Stream',
            subtitle: 'Play a .m3u8 HLS stream',
            onTap: () => _push(context, const HlsExampleScreen()),
          ),
          _ExampleTile(
            icon: Icons.folder,
            title: 'Asset Video',
            subtitle: 'Play a bundled Flutter asset',
            onTap: () => _push(context, const AssetExampleScreen()),
          ),
          _ExampleTile(
            icon: Icons.storage,
            title: 'File / Offline',
            subtitle: 'Local file source with error handling',
            onTap: () => _push(context, const FileExampleScreen()),
          ),
          _ExampleTile(
            icon: Icons.high_quality,
            title: 'Quality Selector',
            subtitle: 'Switch between MP4 quality levels',
            onTap: () => _push(context, const QualityExampleScreen()),
          ),
          _ExampleTile(
            icon: Icons.subtitles,
            title: 'Subtitles',
            subtitle: 'WebVTT subtitle tracks',
            onTap: () => _push(context, const SubtitlesExampleScreen()),
          ),
          _ExampleTile(
            icon: Icons.tune,
            title: 'Custom Controls',
            subtitle: 'Replace default controls with your own UI',
            onTap: () => _push(context, const CustomControlsScreen()),
          ),
          _ExampleTile(
            icon: Icons.analytics,
            title: 'Tracking / Analytics',
            subtitle: 'Observe playback events',
            onTap: () => _push(context, const TrackingExampleScreen()),
          ),
          _ExampleTile(
            icon: Icons.screen_lock_landscape,
            title: 'Wakelock',
            subtitle: 'Keep screen on during playback',
            onTap: () => _push(context, const WakelockExampleScreen()),
          ),
          _ExampleTile(
            icon: Icons.refresh,
            title: 'Retry / Error',
            subtitle: 'Error overlay with configurable retry',
            onTap: () => _push(context, const RetryExampleScreen()),
          ),
          _ExampleTile(
            icon: Icons.smart_display,
            title: 'Reels',
            subtitle: 'Vertical video feed (PageView-based)',
            onTap: () => _push(context, const ReelsExampleScreen()),
          ),
          _ExampleTile(
            icon: Icons.security,
            title: 'Screen Protection',
            subtitle: 'Block recording and screenshot detection',
            onTap: () => _push(context, const ProtectionExampleScreen()),
          ),
        ],
      ),
    );
  }

  void _push(BuildContext context, Widget screen) {
    Navigator.of(context).push(MaterialPageRoute(builder: (_) => screen));
  }
}

class _ExampleTile extends StatelessWidget {
  const _ExampleTile({
    required this.icon,
    required this.title,
    required this.subtitle,
    required this.onTap,
  });

  final IconData icon;
  final String title;
  final String subtitle;
  final VoidCallback onTap;

  @override
  Widget build(BuildContext context) {
    return ListTile(
      leading: Icon(icon, color: Theme.of(context).colorScheme.primary),
      title: Text(title),
      subtitle: Text(subtitle),
      trailing: const Icon(Icons.chevron_right),
      onTap: onTap,
    );
  }
}
24
likes
150
points
53
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A flexible, production-ready Flutter video player package supporting MP4, HLS, reels, quality switching, subtitles, and more. Works on Android, iOS, macOS, and Web.

Repository (GitHub)
View/report issues

Topics

#video #video-player #media #streaming #hls

Funding

Consider supporting this project:

www.patreon.com

License

MIT (license)

Dependencies

dio, flutter, http, plugin_platform_interface, video_player, wakelock_plus

More

Packages that depend on flex_video_player