all_in_one_video_player 0.0.3
all_in_one_video_player: ^0.0.3 copied to clipboard
A Flutter video player that supports YouTube, Vimeo, and server links with custom controls.
all_in_one_video_player #
A Flutter package providing an all-in-one video player widget that supports:
- βΆοΈ YouTube (via WebView)
- π Vimeo (via WebView)
- π Server-hosted videos (MP4/HLS) using
video_player
It comes with a unified fullscreen experience, custom controls for server videos, and clean switching between sources β ideal for any modern Flutter app.
β¨ Features #
-
β Multi-source video playback (YouTube, Vimeo, Server)
-
π§ Unified fullscreen toggle (handles orientation + system UI)
-
π§© Custom video controls for server videos:
- Play/Pause
- Mute/Unmute
- Seek Forward/Backward
- Progress bar with auto-hide
-
β οΈ Error UI for invalid URLs or playback issues
π Quick Start #
1. Add Dependencies #
Add to your pubspec.yaml
:
dependencies:
all_in_one_video_player: ^0.0.3
Run:
flutter pub get
2. Android Setup #
For HTTP video URLs, allow cleartext traffic:
android/app/src/main/AndroidManifest.xml
<application
android:usesCleartextTraffic="true"
... />
3. iOS Setup #
In ios/Runner/Info.plist
, allow insecure video loads (if needed):
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
4. Initialize Flutter #
Call this at the top of your main()
:
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp());
}
π§βπ» Usage for Flutter Developers #
Step 1: Import #
import 'package:all_in_one_video_player/all_in_one_video_player.dart';
Step 2: Choose a source type #
final PlayerController _youtubeController = PlayerController(
videoUrl:
'https://youtu.be/aPCl90cpdDo?si=_xKtFJyqqgH1S9dU', // Example YouTube video it
sourceType: VideoSourceType.youtube,
);
final PlayerController _vimeoController = PlayerController(
videoUrl: 'https://vimeo.com/347119375', // Example Vimeo video
sourceType: VideoSourceType.vimeo,
);
final PlayerController _serverController = PlayerController(
videoUrl:
'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4', // Example server video (MP4)
sourceType: VideoSourceType.server,
);
Hereβs the updated README.md
Step 3 section, with the fix added for YouTube short links:
β Step 3: Use in UI #
Supports YouTube short URLs like:
https://youtu.be/
Example usage:
final youtubeController = PlayerController(
videoUrl: 'https://youtu.be/aPCl90cpdDo',
sourceType: VideoSourceType.youtube,
);
Full UI Example with Buttons #
class VideoPlayerDemoPage extends StatefulWidget {
const VideoPlayerDemoPage({Key? key}) : super(key: key);
@override
State<VideoPlayerDemoPage> createState() => _VideoPlayerDemoPageState();
}
class _VideoPlayerDemoPageState extends State<VideoPlayerDemoPage> {
final _youtube = PlayerController(
videoUrl: 'https://youtu.be/aPCl90cpdDo?si=_xKtFJyqqgH1S9dU',
sourceType: VideoSourceType.youtube,
);
final _vimeo = PlayerController(
videoUrl: 'https://vimeo.com/264560738',
sourceType: VideoSourceType.vimeo,
);
final _server = PlayerController(
videoUrl: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
sourceType: VideoSourceType.server,
);
late PlayerController _current;
bool _isFullScreen = false;
@override
void initState() {
super.initState();
_current = _youtube;
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: _isFullScreen ? null : AppBar(title: const Text('All-in-One Player')),
body: Column(
children: [
AspectRatio(
aspectRatio: 16 / 9,
child: PlayerWidget(
controller: _current,
onFullScreenToggle: (value) => setState(() => _isFullScreen = value),
),
),
if (!_isFullScreen)
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ElevatedButton(onPressed: () => setState(() => _current = _youtube), child: const Text("YouTube")),
ElevatedButton(onPressed: () => setState(() => _current = _vimeo), child: const Text("Vimeo")),
ElevatedButton(onPressed: () => setState(() => _current = _server), child: const Text("Server")),
],
),
],
),
);
}
}
β οΈ Notes #
- πΊ Some YouTube/Vimeo videos may be blocked from embedding due to licensing or content settings.
- π Web support is not included (this is Android/iOS only).
- π± On Android, hybrid composition is used for WebView.
π¨βπ» Author #
Md. Rahul Reza π rahulreza.com π¬ contact@rahulreza.com