youtube_player 2.0.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 95

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 <video id> or <link>
  • No need for API Key and no Limitations

DEMO

New Features in v2.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: ^2.0.0

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.
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.
controlsColorSets color of controls like play, pause, etc.Optional. Default = White
controlsBackgroundColorSets background color of controls like play, pause, etc.Optional. Default = Transparent
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.

[2.0.0] - February 3, 2019.

  • Breaking change. [context] property is required now.
  • Redesigned controls to match original YouTube experience.
  • Fast forward and Rewind feature added, on double tap.
  • Can now adjust video quality through player.
  • Can now share videos with other apps.
  • Size of player can be adjusted.
  • [FIXED] Stretching portrait videos.

[1.0.0] - February 1, 2019.

  • Breaking change. Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to also migrate if they're using the original support library.
  • AutoPlay property added.

[0.8.1] - January 29, 2019.

  • Minor bug fixes.

[0.8.0] - January 29, 2019.

  • (Fixed) Defining controller is optional now.
  • (Fixed) Video not disposing issue. Thanks to [@Y-ndm] for raising the issue.

[0.7.2] & [0.7.1] - January 26, 2019.

  • Minor Fixes.

[0.7.0] - January 26, 2019.

  • Video loads and plays lot more faster than in previous versions.
  • Availability of controller outside the player, for in-depth customizations and events access See Example
  • (FIXED) Aspect ratio and orientation problem in videos.
  • (UNDER THE HOOD) Optimized Youtube Stream Link generation.
  • (UNDER THE HOOD) Reduced dependencies. Significant reduction in code reference.
  • Added controls customization.

[0.6.1] - January 11, 2019.

  • (FIXED) Video continuing to play on background. Thanks to [@ParthAggarwal1996] for raising the issue.
  • Dependency Update

[0.6.0] - January 5, 2019.

  • Videos play faster now.
  • Shows video thumbnail on loading.
  • Changed dependency to 'http' in place of 'dio' in order to reduce amount of code reference.
  • Automatic Fallback to lower quality if higher qualities are not available.
  • (FIXED) 'Default Interface Methods are only supported...' error.
  • (FIXED) Control bar not showing on single tap(after loading).
  • (FIXED) Depreciated Warnings
  • Support for Live Stream Video Playback Added (but not playing yet, will be fixed in next update on finding workaround).

[0.5.0] - January 5, 2019.

  • Minor Changes.

[0.4.0] - January 4, 2019.

  • Fixed some bugs with controls and orientation change.

[0.3.0] - January 4, 2019.

  • ReadMe File Updated. Fixed some bugs.

[0.2.0] - January 3, 2019.

  • Updated Controls.

[0.1.0] - January 2, 2019.

  • Initial Release.

example/README.md

youtube_player_example #

More Detailed Example

class _MyHomePageState extends State<MyHomePage> {
  TextEditingController _idController = TextEditingController();
  String id = "nPt8bK2gbaU";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
              YoutubePlayer(
                context: context,
                source: id,
                quality: YoutubeQuality.HD,
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: TextFormField(
                  controller: _idController,
                  decoration: InputDecoration(
                    border: OutlineInputBorder(),
                    hintText: "Enter youtube \<video id\> or \<link\>"
                  ),
                ),
              ),
              RaisedButton(
                onPressed: () {
                  setState(() {
                    id = _idController.text;
                  });
                },
                child: Text("Play"),
              ),
            ],
          ),
        ));
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  youtube_player: ^2.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:youtube_player/youtube_player.dart';
  
Version Uploaded Documentation Archive
3.3.0 Apr 21, 2019 Go to the documentation of youtube_player 3.3.0 Download youtube_player 3.3.0 archive
3.2.2 Apr 17, 2019 Go to the documentation of youtube_player 3.2.2 Download youtube_player 3.2.2 archive
3.2.1 Apr 12, 2019 Go to the documentation of youtube_player 3.2.1 Download youtube_player 3.2.1 archive
3.2.0 Apr 1, 2019 Go to the documentation of youtube_player 3.2.0 Download youtube_player 3.2.0 archive
3.1.1+3 Feb 24, 2019 Go to the documentation of youtube_player 3.1.1+3 Download youtube_player 3.1.1+3 archive
3.1.1+2 Feb 24, 2019 Go to the documentation of youtube_player 3.1.1+2 Download youtube_player 3.1.1+2 archive
3.1.1+1 Feb 24, 2019 Go to the documentation of youtube_player 3.1.1+1 Download youtube_player 3.1.1+1 archive
3.1.1 Feb 24, 2019 Go to the documentation of youtube_player 3.1.1 Download youtube_player 3.1.1 archive
3.1.0 Feb 19, 2019 Go to the documentation of youtube_player 3.1.0 Download youtube_player 3.1.0 archive
3.0.2 Feb 17, 2019 Go to the documentation of youtube_player 3.0.2 Download youtube_player 3.0.2 archive

All 29 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
90
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
95
Learn more about scoring.

We analyzed this package on Apr 4, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14
  • Flutter: 1.4.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
meta ^1.1.6 1.1.6 1.1.7
screen ^0.0.4 0.0.5
share ^0.6.0 0.6.0+1
Transitive dependencies
collection 1.14.11
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8