custom_youtube_player 1.1.0 copy "custom_youtube_player: ^1.1.0" to clipboard
custom_youtube_player: ^1.1.0 copied to clipboard

A customizable YouTube player widget for Flutter that supports both portrait and landscape modes with fullscreen capabilities.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:custom_youtube_player/custom_youtube_player.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Custom YouTube Player Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData.dark().copyWith(
        primaryColor: Colors.red,
        scaffoldBackgroundColor: Colors.grey[900],
      ),
      home: const HomeScreen(),
    );
  }
}

class HomeScreen extends StatelessWidget {
  const HomeScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Custom YouTube Player Demo'),
        backgroundColor: Colors.red,
        elevation: 0,
      ),
      body: ListView(
        padding: const EdgeInsets.all(16),
        children: [
          _buildSection(
            context,
            'Portrait Video (Shorts)',
            'A vertical video format perfect for mobile viewing',
            const CustomYouTubePlayer(
              videoId: 'vmGv4ntvD10', // Example Shorts video
              isPortrait: true,
            ),
          ),
          const SizedBox(height: 30),
          _buildSection(
            context,
            'Landscape Video',
            'Traditional horizontal video format',
            const CustomYouTubePlayer(
              videoId: 'dQw4w9WgXcQ', // Example landscape video
              isPortrait: false,
            ),
          ),
          const SizedBox(height: 30),
          _buildSection(
            context,
            'Music Video',
            'Perfect for playing music videos in your app',
            const CustomYouTubePlayer(
              videoId: '9bZkp7q19f0', // Gangnam Style
              isPortrait: false,
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildSection(
    BuildContext context,
    String title,
    String description,
    Widget player,
  ) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          title,
          style: const TextStyle(
            fontSize: 20,
            fontWeight: FontWeight.bold,
            color: Colors.white,
          ),
        ),
        const SizedBox(height: 8),
        Text(
          description,
          style: TextStyle(
            fontSize: 14,
            color: Colors.grey[400],
          ),
        ),
        const SizedBox(height: 16),
        Container(
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(8),
            boxShadow: [
              BoxShadow(
                color: Colors.black.withOpacity(0.2),
                blurRadius: 8,
                offset: const Offset(0, 4),
              ),
            ],
          ),
          child: ClipRRect(
            borderRadius: BorderRadius.circular(8),
            child: player,
          ),
        ),
      ],
    );
  }
}
1
likes
160
points
41
downloads

Publisher

unverified uploader

Weekly Downloads

A customizable YouTube player widget for Flutter that supports both portrait and landscape modes with fullscreen capabilities.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, youtube_player_flutter

More

Packages that depend on custom_youtube_player