๐ฅ Adaptive Video Player
The only Flutter video player that supports YouTube + Direct videos on ALL platforms with one widget.
A comprehensive Flutter video player package that seamlessly handles both YouTube videos and direct video URLs with adaptive player selection. Works beautifully on Android, iOS, macOS, Windows, Linux, and Web.
โก 10-Second Quick Start
AdaptiveVideoPlayer(
config: VideoConfig(
videoUrl: "https://youtu.be/VIDEO_ID",
),
);
(Just drop it in and it automatically adapts to YouTube or direct MP4/HLS streams!)
๐ฅ Demo
| Android | iOS |
|---|---|
![]() |
![]() |
| Windows | macOS |
|---|---|
![]() |
![]() |
| Web |
|---|
![]() |
โจ Features
๐ฌ Adaptive Video Player
- Smart Detection โ Automatically detects YouTube vs direct video URLs
- Unified API โ Single
AdaptiveVideoPlayerwidget for all video types - Cross-Platform โ Runs beautifully on Android, iOS, macOS, Windows, Linux, and Web!
๐บ YouTube Player
- Full YouTube video support with native-like experience
- Custom controls on mobile (seek, settings, fullscreen)
- YouTube native controls on Desktop & Web
- Auto-play, loop, captions, mute, force HD
- Force Desktop Mode on mobile (
forceDesktopMode: trueto use WebViews on Android/iOS) - Settings panel with runtime toggles
- Fullscreen mode with state preservation
- Safe External Link Handling (Opens YouTube external URLs in system browser)
- Live Stream Support with "LIVE" indicator and Viewer Count
๐๏ธ Normal Video Player
- Supports MP4, MOV, AVI, MKV, WebM, M4V, 3GP, and more
- Network streaming, local file, and in-memory bytes playback
- Built-in advanced adaptive controls
- Error handling with customizable messages
- Quality Selection (Resolution/source picker)
- Subtitle/CC Support (SRT/VTT formats)
- Custom UI Builders (
controlsBuilder,subtitleBuilder)
๐ Why Adaptive Video Player?
Here is how adaptive_video_player compares to other popular video packages:
| Feature | adaptive_video_player |
youtube_player_flutter |
chewie |
video_player |
|---|---|---|---|---|
| YouTube + MP4 URLs | โ | โ | โ | โ |
| Desktop Support | โ | โ | โ ๏ธ | โ ๏ธ |
| Live Stream Support | โ | โ | โ | โ |
| Unified API | โ | โ | โ | โ |
| Quality Selection | โ | โ | โ | โ |
| External Link Safety | โ | โ | โ | โ |
๐ฅ๏ธ Platform-Specific YouTube Behavior
| Platform | Engine | Controls |
|---|---|---|
| Android / iOS | youtube_player_flutter |
Custom Flutter controls (seek, settings, fullscreen). Can be forced to Desktop Mode. |
| macOS / Windows / Linux | InAppWebView + localhost server |
YouTube native controls |
| Web | HTML iframe (package:web) |
YouTube native controls |
Why localhost on Desktop (Windows, macOS, Linux)? YouTube blocks iframe embedding from local files like
data:andfile://(Error 153). Serving viahttp://localhostprovides a trusted origin that YouTube allows.
๐ฆ Installation
Add to your pubspec.yaml:
dependencies:
adaptive_video_player: ^1.2.3
๐ Platform Permissions & Setup
To ensure network videos and YouTube play correctly across devices, please configure the required platform permissions:
๐ค Android
Ensure you have the INTERNET permission in your android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET"/>
(Required) For playing http:// video URLs AND for using forceDesktopMode: true on Android, you must add usesCleartextTraffic to your <application> tag:
<application
...
android:usesCleartextTraffic="true">
๐ iOS
To allow the YouTube player (which uses Platform Views) to render without being stuck on a loading screen, add the following to your ios/Runner/Info.plist:
<key>io.flutter.embedded_views_preview</key>
<true/>
(Optional) For loading http:// (unencrypted) video URLs safely, also add:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
๐ macOS
For network video playback and YouTube webview support on macOS, you must grant the application permission to act as a network client.
Open macos/Runner/DebugProfile.entitlements and macos/Runner/Release.entitlements and add the following:
<key>com.apple.security.network.client</key>
<true/>
๐ช Windows
YouTube playback on Windows requires NuGet for the flutter_inappwebview build:
winget install Microsoft.NuGet
For normal video playback (MP4s, etc.) on Windows, register the video player plugin in main():
import 'package:flutter/foundation.dart';
import 'package:video_player_win/video_player_win_plugin.dart';
void main() {
if (!kIsWeb && defaultTargetPlatform == TargetPlatform.windows) {
WindowsVideoPlayer.registerWith();
}
runApp(const MyApp());
}
๐ง Linux
Linux requires WebKit for the flutter_inappwebview playback. Ensure your system has the necessary GTK/WebKit packages installed (e.g., libwebkit2gtk-4.1-dev on Ubuntu/Debian).
๐ Web
No specific permission files are needed. However, ensure that any external direct videos (MP4, MKV) you stream are hosted on servers with CORS (Cross-Origin Resource Sharing) enabled. YouTube videos are handled automatically via iframe.
๐ Quick Start
import 'package:adaptive_video_player/adaptive_video_player.dart';
// YouTube video โ detected automatically
AdaptiveVideoPlayer(
config: VideoConfig(
videoUrl: 'https://www.youtube.com/watch?v=vM2dC8OCZoY',
),
)
// Direct video โ detected automatically
AdaptiveVideoPlayer(
config: VideoConfig(
videoUrl: 'https://example.com/video.mp4',
),
)
๐ Usage Examples
YouTube with Custom Config
AdaptiveVideoPlayer(
config: VideoConfig(
videoUrl: 'https://www.youtube.com/watch?v=vM2dC8OCZoY',
playerConfig: YouTubePlayerConfig(
playback: PlayerPlaybackConfig(
autoPlay: true,
loop: false,
forceHD: true,
enableCaption: true,
forceDesktopMode: true, // Uses WebViews on Android/iOS instead of native player
),
style: PlayerStyleConfig(
iconColor: Colors.white,
progressBarPlayedColor: Colors.red,
progressBarHandleColor: Colors.redAccent,
backgroundColor: Colors.black,
),
visibility: PlayerVisibilityConfig(
showSettingsButton: true,
showFullscreenButton: true,
),
),
),
)
Local Video File
AdaptiveVideoPlayer(
config: VideoConfig(
videoUrl: '/path/to/local/video.mp4',
isFile: true,
),
)
Video from Memory
AdaptiveVideoPlayer(
config: VideoConfig(
videoUrl: '',
videoBytes: myUint8ListBytes,
),
)
Live Stream Example
AdaptiveVideoPlayer(
config: VideoConfig(
videoUrl: 'https://www.youtube.com/watch?v=YOUR_LIVE_VIDEO_ID',
isLive: true,
viewerCount: '1.2K', // Optional viewer count for the LIVE badge
),
)
๐๏ธ Configuration Reference
VideoConfig
| Property | Type | Default | Description |
|---|---|---|---|
videoUrl |
String |
required | Video target URL |
isFile |
bool |
false |
True if the URL is a local file path |
isLive |
bool |
false |
Enables LIVE indicator and disables seek bar |
viewerCount |
String? |
null |
Displayed when isLive is true |
qualities |
List<VideoQuality>? |
null |
Available qualities or sources |
subtitles |
List<SubtitleTrack>? |
null |
Available subtitle tracks |
controlsBuilder |
AdaptiveControlsBuilder? |
null |
Custom controls overlay builder |
subtitleBuilder |
SubtitleBuilder? |
null |
Custom subtitles UI builder |
playerConfig |
YouTubePlayerConfig |
const YouTubePlayerConfig() |
YouTube specific settings |
YouTubePlayerConfig
PlayerPlaybackConfig
| Property | Type | Default | Description |
|---|---|---|---|
autoPlay |
bool |
false |
Auto-start playback |
loop |
bool |
false |
Loop video |
mute |
bool |
false |
Start muted |
forceHD |
bool |
false |
Force HD quality |
enableCaption |
bool |
false |
Enable captions |
forceDesktopMode |
bool |
false |
Use WebView player on Android/iOS |
allowExternalLinks |
bool |
true |
Open external links in system browser |
PlayerStyleConfig
| Property | Type | Default | Description |
|---|---|---|---|
progressBarPlayedColor |
Color |
Colors.red |
Progress bar color |
progressBarHandleColor |
Color |
Colors.redAccent |
Handle color |
iconColor |
Color |
Colors.white |
Control icons color |
textColor |
Color |
Colors.white |
Text color |
backgroundColor |
Color |
#1D1D1D |
Player background |
loadingIndicatorColor |
Color |
Colors.red |
Loading spinner color |
errorIconColor |
Color |
Colors.red |
Error icon color |
settingsBackgroundColor |
Color |
#1D1D1D |
Settings sheet background |
PlayerTextConfig
| Property | Type | Default |
|---|---|---|
invalidYoutubeUrlText |
String |
"Invalid YouTube URL" |
videoLoadFailedText |
String |
"Failed to load video" |
playerSettingsText |
String |
"Player Settings" |
autoPlayText |
String |
"Auto Play" |
loopVideoText |
String |
"Loop Video" |
forceHdQualityText |
String |
"Force HD Quality" |
enableCaptionsText |
String |
"Enable Captions" |
muteAudioText |
String |
"Mute Audio" |
PlayerVisibilityConfig
| Property | Type | Default |
|---|---|---|
showControls |
bool |
true |
showFullscreenButton |
bool |
true |
showSettingsButton |
bool |
true |
showAutoPlaySetting |
bool |
true |
showLoopSetting |
bool |
true |
showForceHDSetting |
bool |
true |
showCaptionsSetting |
bool |
true |
showMuteSetting |
bool |
true |
๐๏ธ Architecture
lib/
โโโ adaptive_video_player.dart # Package exports & Smart YouTube/direct video detection
โโโ src/
โโโ normal_video_player/
โ โโโ normal_video_player.dart # Native video player component
โ โโโ adaptive_controls.dart # Core UI controls overlay builder
โ โโโ model/
โ โโโ video_config.dart # Video configuration model
โโโ youtube_player/
โโโ youtube_video_player.dart # Main YouTube player (platform-aware)
โโโ cubit/
โ โโโ youtube_player_cubit.dart # BLoC state management
โ โโโ youtube_player_state.dart
โโโ models/
โ โโโ player_config.dart # YouTube player config models
โโโ utils/
โ โโโ player_utils.dart # Player utility functions
โ โโโ youtube_web_actual.dart # Web iframe implementation
โ โโโ youtube_web_export.dart # Conditional export
โ โโโ youtube_web_stub.dart # Stub for non-web
โโโ widgets/
โโโ youtube_webview_player.dart # Desktop WebView player (localhost)
โโโ player_controls.dart # Seek overlay, loading, error widgets
โโโ player_bottom_actions.dart # Bottom action bar builder
โโโ player_settings_sheet.dart # Settings bottom sheet
โโโ player_settings_helper.dart # Settings helper
โโโ setting_item.dart # Individual setting toggle
โโโ fullscreen_player_page.dart # Fullscreen player page
๐ง Supported Formats
YouTube URLs:
youtube.com/watch?v=... ยท youtu.be/... ยท youtube.com/embed/... ยท m.youtube.com/watch?v=... ยท Direct Video IDs
Video Files: MP4 ยท MOV ยท AVI ยท MKV ยท WebM ยท M4V ยท 3GP ยท FLV ยท WMV
โ FAQ
Q: I get "Error 153" on Windows Desktop.
A: This is handled automatically. The package serves YouTube via http://localhost to bypass the restriction.
Q: I get "NuGet is not installed" on Windows.
A: Run winget install Microsoft.NuGet and restart your IDE.
Q: MP4 videos don't play on Windows.
A: Add WindowsVideoPlayer.registerWith() in your main() before runApp().
Q: Does it work on macOS/Linux?
A: Desktop support uses InAppWebView which primarily supports Windows. macOS/Linux support depends on flutter_inappwebview platform availability.
๐ฎ Roadmap (Future Features)
We are actively working to make this the ultimate video player. Upcoming features:
- Playlist Support:
AdaptiveVideoPlaylist(videos: [...]) - Analytics Callbacks:
onPlay,onPause,onCompleted,onError - Picture in Picture (PiP): Native PiP support for Android & iOS.
(Got a feature request? Open an issue!)
๐ค Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This project is licensed under the MIT License โ see the LICENSE file for details.
๐จ๐ป Author
Ahmed Mohamed Alam ยท GitHub: @ahmedalam782
๐ Dependencies
- youtube_player_flutter โ YouTube player for mobile
- flutter_inappwebview โ WebView for Desktop YouTube
- video_player โ Flutter's official video player
- video_player_media_kit โ Linux video playback via media_kit
- video_player_win โ Windows video playback via Media Foundation
- flutter_bloc โ State management
- url_launcher โ Launching external URLs safely
- web โ Modern Web APIs for WASM compatibility




