all_in_one_video_player 0.0.3 copy "all_in_one_video_player: ^0.0.3" to clipboard
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


0
likes
160
points
60
downloads

Publisher

verified publisherrahulreza.com

Weekly Downloads

A Flutter video player that supports YouTube, Vimeo, and server links with custom controls.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, video_player, webview_flutter

More

Packages that depend on all_in_one_video_player