Flutter Native Player for Flutter
A Flutter plugin for Android, iOS for playing back video on a Widget surface.
Installation
Copy and paste to dependencies:
flutter_native_player: ^1.0.4
Note: iOS requires 9.0 or higher and Android requires SDK 16 or higher
Example:
import 'package:flutter/material.dart';
import 'package:flutter_native_player/flutter_native_player.dart';
import 'package:flutter_native_player/model/player_resource.dart';
import 'package:flutter_native_player/model/player_subtitle_resource.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String videoUrl = "https://d2cqvl54b1gtkt.cloudfront.net/PRODUCTION/5d85da3fa81ada4c66211a07/post/media/video/1616987127933-bfc1a13a-49c6-4272-8ffd-dc04b05eed2c/1616987128057-740d153b431660cf976789c1901192a961f0fd5b2a2af43e2388f671fa03c2aa/1616987128057-740d153b431660cf976789c1901192a961f0fd5b2a2af43e2388f671fa03c2aa.m3u8";
final playerSubtitleResource = [
PlayerSubtitleResource(
language: "English",
subtitleUrl: "https://raw.githubusercontent.com/Pisey-Nguon/Player-Resource/master/English_Transformers_The_Last_Knight_Official_Trailer_1_2017_Michael.srt",
),
PlayerSubtitleResource(
language: "Khmer",
subtitleUrl: "https://raw.githubusercontent.com/Pisey-Nguon/Player-Resource/master/Khmer_Transformers_The_Last_Knight_Official_Trailer_1_2017_Michael.srt",
)
];
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Flutter Native Player'),
),
body: Center(
child: FlutterNativePlayer(
playerResource: PlayerResource(videoUrl: videoUrl, playerSubtitleResource: playerSubtitleResource),
playWhenReady: true,
width: double.infinity,
height: 250
),
),
),
);
}
}
Configuration:
- playWhenReady if it's true it's going to play immediately after fetching data success but if it's false that after fetching data success it's not played.
- playerSubtitleResource if null or empty list it's going to hide subtitle button.
Supported Formats
- For Android, the backing player is ExoPlayer, please refer here for list of supported formats.
- For iOS, the backing player is AVPlayer. The supported formats vary depending on the version of iOS, AVURLAsset class has audiovisualTypes that you can query for supported av formats.
Libraries
- constant
- custom_controller/configuration/player_progress_colors
- custom_controller/material/dialog/player_clickable_widget
- custom_controller/material/dialog/player_material_bottom_sheet
- custom_controller/material/progress_bar/audio_video_progress_bar
- custom_controller/player_overlay/player_controller
- custom_controller/player_overlay/player_loading
- custom_controller/player_overlay/player_overlay_controller
- custom_controller/player_overlay/player_widget
- flutter_native_getx_controller
- flutter_native_player
- hls/fetch_hls_master_playlist
- hls/hls_parser/drm_init_data
- hls/hls_parser/exception
- hls/hls_parser/format
- hls/hls_parser/hls_master_playlist
- hls/hls_parser/hls_media_playlist
- hls/hls_parser/hls_playlist_parser
- hls/hls_parser/hls_track_metadata_entry
- hls/hls_parser/metadata
- hls/hls_parser/mime_types
- hls/hls_parser/playlist
- hls/hls_parser/rendition
- hls/hls_parser/scheme_data
- hls/hls_parser/segment
- hls/hls_parser/util
- hls/hls_parser/variant
- hls/hls_parser/variant_info
- hls/player_kid_data_holder
- hls/player_kid_hls_utils
- hls/player_kid_track
- hls/player_kid_utils
- method_manager/download_state
- method_manager/playback_state
- method_manager/player_method_manager
- model/duration_state
- model/playback_speed
- model/player_resource
- model/player_subtitle_resource
- model/quality_model
- subtitles/player_kid_subtitle
- subtitles/player_kid_subtitle_segment
- subtitles/player_kid_subtitles_configuration
- subtitles/player_kid_subtitles_drawer
- subtitles/player_kid_subtitles_factory
- subtitles/player_kid_subtitles_source
- subtitles/player_kid_subtitles_source_type
- utils/time_utils