📜  youtube_player_flutter flutter (1)

📅  最后修改于: 2023-12-03 15:06:07.089000             🧑  作者: Mango

YouTube Player Flutter

YouTube Player Flutter Logo

Introduction

YouTube Player Flutter is a Flutter plugin that allows playing YouTube videos seamlessly in a Flutter app. With YouTube Player Flutter, developers can include YouTube videos within their apps and customize the player according to their requirements.

Features
  • Play YouTube videos within a Flutter app.
  • Control YouTube video playback.
  • Customize the player as per the app's design.
  • Set video quality (auto, 144p, 240p, 360p, 480p, 720p, 1080p, and more).
  • Show/hide player controls.
  • Detect and handle player errors.
  • Support both Android and iOS.
Installation

Add the following dependency to your pubspec.yaml file:

dependencies:
  youtube_player_flutter: ^b.latest_version_number

Run the command flutter pub get to install the package.

Usage

Import the package in your dart file:

import 'package:youtube_player_flutter/youtube_player_flutter.dart';

Create a YoutubePlayerController object:

YoutubePlayerController _controller = YoutubePlayerController(
  initialVideoId: 'VIDEO_ID',
  flags: YoutubePlayerFlags(
    autoPlay: true,
    mute: false,
  ),
);

Create a YoutubePlayer widget and pass the YoutubePlayerController object as a parameter:

YoutubePlayer(
  controller: _controller,
  showVideoProgressIndicator: true,
),
Conclusion

YouTube Player Flutter is a versatile plugin that enables developers to integrate YouTube videos seamlessly within their Flutter apps. With its features, developers can provide their users with an enhanced viewing experience.

For more information, visit https://pub.dev/packages/youtube_player_flutter.