flutube 0.8.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 94

FluTube #

Embed Youtube videos in your flutter apps just by passing in the video URL!

PLEASE NOTE: Embedding copyrighted videos is actually not possible. Please use flutter_youtube instead.

This plugin uses an in-built API so the official YT API is not used here and therefore you don't need any API keys.

This plugin also uses the great plugin Chewie to provide a nice material or cupertino video player. And please note this plugin is NOT a replacement for Chewie. Chewie is a great plugin and here we are just using it.

Huge thank you to @brianegan for developing Chewie.

Demo #

Demo

Installation #

In your pubspec.yaml file within your Flutter Project:

dependencies:
  flutube: ^0.8.3

Use it #

import 'package:flutube/flutube.dart';

final flutubePlayer = FluTube(
  '<Youtube URL>',
  aspectRatio: 16 / 9,
  autoPlay: true,
  looping: true,
  onVideoStart: () {},
  onVideoEnd: () {},
);

Example #

Please run the app in the example/ folder to start playing!

0.8.3 #

  • Fix object types

0.8.2 #

  • Support for multiple YouTube URL schemas (#20) (thanks to @alanpachuau)

0.8.1 #

  • Fix typo (thanks to @marcosgallardo)

0.8.0 #

  • Added native support for playlists
  • Fix looping bug
  • Fix #9 & #10 (thanks to @murilobaixou)

0.7.3 #

  • Small bug fix

0.7.2 #

  • Deleted unnecesary files
  • Updated dependencies

0.7.1 #

  • Added options to allow muting, prevent screen sleep and controlling fullscreen mode.

0.7.0 #

  • Updated to work with Chewie ^0.9.0

0.6.2 #

  • Fix copy-paste issue

0.6.1 #

  • Fix minor bugs

0.6.0 #

  • Fixed bugs and added example on how to implement a playlist

0.5.2 #

  • Fixed possible stack overflow on videoEnd callback.

0.5.1 #

  • Fixed autoPlay not working due to video thumbnail
  • Added fullscreenByDefault property

0.5.0 #

  • Added onVideoStart and onVideoEnd (extremely useful) callbacks

0.4.3-4 #

  • Revert 0.4.2 as it was not working

0.4.1-2 #

  • Changed dispose approach trying to fix some errors derived from video disposal

0.4.0 #

  • Added thumbnail to videos (thumbnail loads directly from YT). You can control whether you want to display the original video thumbnail with the showThumb property. The default value is true.

0.3.1 #

  • Fix bugs
  • You can now access the inner video controller via GlobalKey<FlutubeState>

0.3.0 #

  • Updated Chewie to 0.8.0
  • Removed unnecessary code
  • Fixed bugs

0.2.0 #

  • Fix #2
  • Fixed a potential bug that made videos don't stop playing when route was deactivated

0.1.2 #

  • Fixed a bug which made autoStart property not work without setting autoInitialize to true.

0.1.1 #

  • Updated http dependency to allow installation on all Flutter channels.

0.1.0 #

  • Added in-plugin API. The plugin does not depend anymore on the YT Link Deconstructor hosted on HerokuApp.

0.0.1 #

  • Initial release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutube/flutube.dart';

void main() => runApp(MaterialApp(
  home: MyApp(),
));

class MyApp extends StatefulWidget {
  @override
  MyAppState createState() => MyAppState();
}

class MyAppState extends State<MyApp> {
  final List<String> playlist = <String>[
    'https://www.youtube.com/watch?v=fq4N0hgOWzU',
    'https://youtu.be/IVTjpW3W33s',
  ];
  int currentPos;
  String stateText;

  @override
  void initState() {
    currentPos = 0;
    stateText = "Video not started";
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('FluTube Test'),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: <Widget>[
            Text('Youtube video URL: ${playlist[currentPos]}', style: TextStyle(fontSize: 16.0),),
            FluTube.playlist(
              playlist,
              autoInitialize: true,
              aspectRatio: 16 / 9,
              allowMuting: false,
              looping: true,
              deviceOrientationAfterFullscreen: [
                DeviceOrientation.portraitUp,
                DeviceOrientation.landscapeLeft,
                DeviceOrientation.landscapeRight,
              ],
              systemOverlaysAfterFullscreen: SystemUiOverlay.values,
              onVideoStart: () {
                setState(() {
                  stateText = 'Video started playing!';
                });
              },
              onVideoEnd: () {
                setState(() {
                  stateText = 'Video ended playing!';
                  if((currentPos + 1) < playlist.length)
                    currentPos++;
                });
              },
            ),
            Text(stateText),
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutube: ^0.8.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:flutube/flutube.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
88
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]
94
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Format lib/src/flutube_player.dart.

Run flutter format to format lib/src/flutube_player.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
chewie >=0.9.8 <0.10.0 0.9.10
flutter 0.0.0
http >=0.12.0 <0.13.0 0.12.0+4
Transitive dependencies
async 2.4.1
charcode 1.1.3
collection 1.14.11 1.14.12
flutter_web_plugins 0.0.0
http_parser 3.1.4
meta 1.1.8
open_iconic_flutter 0.3.0
path 1.6.4
pedantic 1.9.0
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
video_player 0.10.8+1
video_player_platform_interface 1.0.5
video_player_web 0.1.2+1
wakelock 0.1.4+1