Code Monkey home page Code Monkey logo

youtube_player's Introduction

Youtube Player Plugin

pub package Build Status licence

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

Released New Youtube Player based on Official Iframe API

This plugin only supports Android. So, published a new plugin youtube_player_flutter which is an officially provided way of playing youtube videos, supporting both Android and iOS platforms.

Note: Will keep on maintaining this plugin too.

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.4.1

2. Install

Run command:

$ flutter packages get

3. Import

Import in Dart code:

import 'package:youtube_player/youtube_player.dart';

4. Using Youtube Player

///
/// LOWEST = 144p
/// 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) {
      _videoController = controller;
    },
),

5. Playing livestream videos

Must set isLive property to true in order to play livestream videos.

YoutubePlayer(
    context: context,
    source: "ddFvjfvPnqk",
    quality: YoutubeQuality.HD,
    **isLive: true,**
),

Note:

In scenario, where one need to navigate to next page and return. You'll need to pause the video before navigating, otherwise the video will keep on playing.

RaisedButton(
    child: Text("Next Page"),
    onPressed: () {
          _videoController.pause();
          Navigator.of(context).push(
               MaterialPageRoute(builder: (context) => NextPage()),
          );
    },
),

Didn't like the controls ?

Don't worry, Got a solution for you. ๐Ÿ˜‰ Set the playermode to NO_CONTROLS, then you can create your own custom controls using the controller obtained from callbackController property.

YoutubePlayer(
    context: context,
    source: "ddFvjfvPnqk",
    playerMode: YoutubePlayerMode.NO_CONTROLS,
    callbackController: (controller) {
      _videoController = controller;
      },
),

Details

Read about all the available properties for the player here.

Example

Example sources

Limitation

Download

Download apk and try the plugin.

Credit

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

License

Copyright (c) 2019 Sarbagya Dhaubanjar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

youtube_player's People

Contributors

sarbagyastha avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.