Youtube Player Plugin

pub package

A flutter plugin to play Youtube Videos "inline" without API Key in range of Qualities(240p, 360p, 480p, 720p and 1080p).

Salient Features

  • Inline playback
  • Thumbnail Support
  • Youtube-like controls
  • Customizable Controls
  • Supports HD and Full HD quality
  • Playable through
  • No need for API Key and no Limitations
  • Supports Live Stream Videos

DEMO

New Features in v3.x.x!

  • Change video quality on-the-fly.
  • Share video with other apps.
  • Fast Forward and Rewind with double tap.
  • Tap-and-hold to enter and exit fullscreen.
  • Auto resize as per the video's aspect ratio.

Usage

1. Depend

Add this to you package's pubspec.yaml file:

dependencies:
  youtube_player: ^3.0.2

2. Install

Run command:

$ flutter packages get

3. Import

Import in Dart code:

import 'package:youtube_player/youtube_player.dart';

4. Using Youtube Player

///
/// LOW = 240p
/// MEDIUM = 360p
/// HIGH = 480p
/// HD = 720p
/// FHD = 1080p
/// "source" can be either youtube video ID or link.
///
YoutubePlayer(
        context: context,
        source: "nPt8bK2gbaU",
        quality: YoutubeQuality.HD,
        // callbackController is (optional). 
        // use it to control player on your own.
        callbackController: (controller) {
            _controller = controller;
        },
),

Details

PropertyDescriptionRemarks
sourceSource of youtube video. Video ID or URLRequired.
contextBuildContext of parent.Required.
qualitySets quality for youtube videos.Required.
isLiveDenotes if the source is Live VideoOptional. Default = false.
aspectRatioSets aspect ratio of player's containerOptional. Default = 16/9
widthSets width of player's containerOptional. Default = Screen width. Must be less than Screen Width.
controlsActiveBackgroundOverlaySets video-wide overlay when controls are activeOptional. Default = true.
controlsColorSets color of controls like play, pause, etc.Optional.
startAtSets the starting position of the video.Optional.
showThumbnailShows thumbnail when video is initializing.Optional. Default = true
keepScreenOnTriggers screen to be on when not in fullscreen.Optional. Default = true
showVideoProgressBarShows progressbar below the video.Optional. Default = true
playerModeSets player mode. YoutubePlayerMode.NO_CONTROLS hides the controls from player. Useful when custom controls are to be build.Optional. Default = YoutubePlayerMode.DEFAULT
onErrorCallback which reports error.Optional.
onVideoEndedCallback which reports end of video.Optional.
callbackControllerCallback which provides current Video Controller.Optional.

Example

Example sources

Limitation

  • Only Available for Android (Currently)

Todos

  • Support for ios
  • Adaptive playback as per the internet bandwidth

Credit

This plugin is a fork of video_player, developed by @Flutter Team.

License

Copyright 2019 Sarbagya Dhaubanjar

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Libraries

controls
youtube_player