m3u8_player 0.0.7 copy "m3u8_player: ^0.0.7" to clipboard
m3u8_player: ^0.0.7 copied to clipboard

Platformweb

A Flutter package that provides a customizable M3U8 player for both mobile and web platforms.

M3U8 Player #

A Flutter package that provides a customizable M3U8 player for both mobile and web platforms.

image WhatsApp Image 2025-03-15 at 20 02 48 WhatsApp Image 2025-03-15 at 20 02 49

Support Me on Ko-fi

Features #

  • Cross-platform Support: Compatible with Android, iOS, and Web.
  • Customizable UI: Easily customize the player's appearance to match your application's theme.
  • Playback Controls: Play, pause, seek, adjust volume, playback speed, and quality of the stream.
  • Fullscreen Mode: Toggle fullscreen mode seamlessly.
  • Progress Callbacks: Receive progress updates at specified intervals.
  • Completion Callback and Threshold: The player triggers an onCompleted callback when the playback reaches the specified completedPercentage (a value between 0 and 1; e.g., 1.0 indicates full completion).

Getting Started #

Installation #

Add m3u8_player to your project's pubspec.yaml:

dependencies:
  m3u8_player:
    git:
      url: https://github.com/MendesCorporation/m3u8_player.git

Then run:

flutter pub get

Usage #

Import the Package

import 'package:m3u8_player/m3u8_player.dart';

Initialize PlayerConfig

Create a PlayerConfig to configure the player:

PlayerConfig config = PlayerConfig(
  url: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
  autoPlay: true,
  loop: false,
  startPosition: 0,
  enableProgressCallback: true,
  progressCallbackInterval: 1,
  onProgressUpdate: (position) {
    // Handle progress update
    print('Current position: ${position.inSeconds} seconds');
  },
  onFullscreenChanged: (isFullscreen) {
    // Handle fullscreen change
    print('Fullscreen mode: $isFullscreen');
  },
  completedPercentage: 0.95,
  onCompleted:(){
  print('Video completo');
  },
  theme: PlayerTheme(
    primaryColor: Colors.blue,
    backgroundColor: Colors.black,
    bufferColor: Colors.grey,
    progressColor: Colors.red,
    iconSize: 24.0,
  ),
);

Embed M3u8PlayerWidget in Your Widget Tree

import 'package:flutter/material.dart';
import 'package:m3u8_player/m3u8_player.dart';

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

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

  @override
  Widget build(BuildContext context) {
    PlayerConfig config = PlayerConfig(
      url: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
      autoPlay: true,
      theme: PlayerTheme(
        primaryColor: Colors.blue,
      ),
    );

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('M3U8 Player Example')),
        body: Center(
          child: M3u8PlayerWidget(config: config),
        ),
      ),
    );
  }
}

Example #

The example folder contains a complete example of how to use the m3u8_player package. To run the example:

  1. Navigate to the example directory:

    cd example
    
  2. Run the example app:

    flutter run
    

API Documentation #

PlayerConfig #

Configuration options for initializing the player.

  • url: String - The HLS stream URL.
  • autoPlay: bool - Enables or disables automatic playback on initialization. Default is false.
  • loop: bool - Enables or disables looping of the stream. Default is false.
  • startPosition: int - Specifies the initial playback position in seconds. Default is 0.
  • enableProgressCallback: bool - Enables progress updates with a specified interval. Default is false.
  • progressCallbackInterval: int - Interval in seconds for the progress callback. Default is 1.
  • onProgressUpdate: void Function(Duration) - Callback for progress updates.
  • onFullscreenChanged: Function(bool)? - Callback for fullscreen state changes.
  • onCompleted: Function(bool)? - Callback for completed watch video.
  • completedPercentage: double - value 0 to 1 for considering completed video.
  • theme: PlayerTheme - Defines theming options for the player.

PlayerTheme #

Defines theming options for the player.

  • primaryColor: Color - Primary color for icons and text.
  • backgroundColor: Color - Background color of the player.
  • bufferColor: Color - Color of the buffer progress.
  • progressColor: Color - Color of the playback progress.
  • iconSize: double - Size of the player icons.

M3u8PlayerWidget #

A widget that embeds the M3U8 Player into your Flutter application.

Constructor

M3u8PlayerWidget({
  Key? key,
  required PlayerConfig config,
})
  • config: PlayerConfig - Configuration for initializing the player.

If you liked this project, consider supporting it with a donation!

Support Me on Ko-fi

Contributing #

Contributions are welcome! Please fork the repository and submit a pull request with your changes.

License #

This project is licensed under the MIT License. See the LICENSE file for details.

Contact #

For support or inquiries, please contact contato@apptrix.app.

5
likes
130
points
493
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package that provides a customizable M3U8 player for both mobile and web platforms.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_hls_parser, flutter_web_plugins, http, js, provider, screen_brightness_platform_interface, video_player, video_player_web, wakelock_plus

More

Packages that depend on m3u8_player