Custom YouTube Player
A customizable YouTube player widget for Flutter that supports both portrait and landscape modes with fullscreen capabilities. This package provides a seamless way to integrate YouTube videos into your Flutter applications with a beautiful and responsive UI.
Features
- 🎥 Support for both portrait and landscape video modes
- 📱 Responsive design that adapts to different screen sizes
- 🔄 Smooth fullscreen transitions
- ⏯️ Video progress tracking and position memory
- 🎨 Customizable player controls and appearance
- 📦 Easy to integrate and use
Installation
Add this to your package's pubspec.yaml
file:
dependencies:
custom_youtube_player: ^1.0.0
Usage
Basic Implementation
import 'package:flutter/material.dart';
import 'package:custom_youtube_player/custom_youtube_player.dart';
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return CustomYouTubePlayer(
videoId: 'YOUR_VIDEO_ID',
isPortrait: false, // Set to true for portrait mode (Shorts)
);
}
}
Fullscreen Support
The player automatically handles fullscreen transitions. When in fullscreen mode, the video will maintain its aspect ratio and provide a native fullscreen experience.
Example with Multiple Videos
import 'package:flutter/material.dart';
import 'package:custom_youtube_player/custom_youtube_player.dart';
class VideoGallery extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ListView(
padding: const EdgeInsets.all(16),
children: const [
Text('Portrait Video (Shorts)', style: TextStyle(fontSize: 18)),
SizedBox(height: 10),
CustomYouTubePlayer(
videoId: 'YOUR_SHORT_VIDEO_ID',
isPortrait: true,
),
SizedBox(height: 30),
Text('Landscape Video', style: TextStyle(fontSize: 18)),
SizedBox(height: 10),
CustomYouTubePlayer(
videoId: 'YOUR_LANDSCAPE_VIDEO_ID',
isPortrait: false,
),
],
);
}
}
Parameters
Parameter | Type | Description |
---|---|---|
videoId | String | The YouTube video ID (required) |
isPortrait | bool | Whether the video should be displayed in portrait mode (default: false) |
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.