The video player for Flutter with a heart of gold

Last update: Jun 22, 2022

chewie

Version CI Generic badge

The video player for Flutter with a heart of gold.

The video_player plugin provides low-level access to video playback. Chewie uses the video_player under the hood and wraps it in a friendly Material or Cupertino UI!

Demo

Demo

Installation

In your pubspec.yaml file within your Flutter Project:

dependencies:
  chewie: <latest_version>
  video_player: <latest_version>

Use it

import 'package:chewie/chewie.dart';
final videoPlayerController = VideoPlayerController.network(
    'https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4');

await videoPlayerController.initialize();

final chewieController = ChewieController(
  videoPlayerController: videoPlayerController,
  autoPlay: true,
  looping: true,
);

final playerWidget = Chewie(
  controller: chewieController,
);

Please make sure to dispose both controller widgets after use. For example by overriding the dispose method of the a StatefulWidget:

@override
void dispose() {
  videoPlayerController.dispose();
  chewieController.dispose();
  super.dispose();
}

Example

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

Migrating from Chewie < 0.9.0

Instead of passing the VideoPlayerController and your options to the Chewie widget you now pass them to the ChewieController and pass that latter to the Chewie widget.

final playerWidget = Chewie(
  videoPlayerController,
  autoPlay: true,
  looping: true,
);

becomes

final chewieController = ChewieController(
  videoPlayerController: videoPlayerController,
  autoPlay: true,
  looping: true,
);

final playerWidget = Chewie(
  controller: chewieController,
);

iOS warning

The video_player plugin used by chewie will only work in iOS simulators if you are on flutter 1.26.0 or above. You may need to switch to the beta channel flutter channel beta Please refer to this issue.

000000000000000KKKKKKKKKKKKXXXXXXXXXXXXXKKKKKKKKKKKKKKKKKKKKKKKKKKK00
000000000000000KKKKKKKKKKKKKXXXXXXXXXXKKKKKKKKKKKKKKKKKKKKKKKKKKKKK00
000000000000000KKKKKKKKKKKKKXXXXXXK0xdoddoclodxOKKKKKKKKKKKKKKKKKKK00
00000000000000KKKKKKKKKKKKKKKK0xoc:;;,;,,,,''';cldxO0KKKKKKKKKKKKK000
00000000000000KKKKKKKKKKKKKKx:'',,,'.,'...;,'''',;:clk0KKKKKKKKKKK000
00000000000000KKKKKKKKKKKKd;'',,,;;;'.,..,c;;,;;;;;:;;d0KKKKKKKKKK000
00000000000000KKKKKKKKKKx,',;:ccl;,c;';,,ol::coolc:;;,,x0KKKKKKKKK000
00000000000000KKKKKKKKOl;:;:clllll;;o;;;cooclddclllllc::kKKKKKKKKK000
00000000000000KKKKKK0o;:ccclccccooo:ooc:ddoddloddolc;;;:c0KKKKKKK0000
00000000000000KKKKKOccodolccclllooddddddxdxddxkkkkxxo;'';d0KKKKKK0000
00000000000000KKKKkcoddolllllclloodxxxxdddxdddxxxddool:'.;O0KKKKK0000
00000000000000000xloollcccc:cclclodkkxxxdddxxxkkxdlllolc,,x0KKKKK0000
0000000000000000xccllccccc:;,'',;:dxkxxddddxkkkxdollcc:cc;d0KKKKKK000
000000000000000kcc:::cllol:'......odxxdoccldxxxdollllc:;;:d0KKKKK0000
00000000000000klc;;;clcc::;'...';;;:cll..',cdddolccccccc;:x0KKKKK0000
0000000000000kdl;:cclllclllc::;,;.'.''o;,,'.;ccoooollllc:;x0KKKKK0000
000000000000kol;:;::coolcc:::,.....,..cd,....':lolclolllc;x0KKKK00000
00000000000Odl;:'cllol;''',;;;;::''.',:doc;,',::looc:lcol:x0K00000000
0000000000Oxl:c,:lolc,..',:clllollodoc;cllolccloolllcclollO0K00000000
0000000000xllc,:lool:'.,...o.;llxdo:loc;;ccodlolodldllolld00K0K000000
000000000Ooc::coooc,,.',;:lx,,...':;o;l;':o:oolccocdoldloO0000KK00000
00000000kol:clllc;;,.;::;:clllllolxc;.:c':ocldlccl;clldox000000000000
000000Odll:cccc;:;,';cllooodoollcloll;c:.:d:ooo;cl;oloddkO00000000000
0000OOddOdll;c,;;,,;;:cldodddoxdoodlcc:.,ox:o:lllocdlodx00O0000000000
000Oxdl:::ll,:,:;,';c,:oloddolkxddxolc.'coccocolcccoooc;oxO00KOOOO000
dc;,'...';c,,:c:::'c:';cldoo;:odolxoc:.,o:oldlxol;lddl,.,lkO0KdlcckKO
'.......,:''';cll:cc,,;:l:c,,;:oc;cdc,.;::dldoxd:ldol;,'..,:lo,,,,kOk
.......';'.',:clcll,,;:l:;'..''c:,;cl'.';dxoooxlddl;',''..,,;'...,ool
.......,,.'';;:cld;.;,do:..;:,':c',:c''';xxdldocol'..';,.......',;;,;
.......'..'',,coxc'';:do'.clc:lco',o;',;cOxdol:cc:.....'..oxd;','.'..
'.......''..,:cxl;';;cx:''cll:clc'cl',:l:ko:c..;c:..';...,KNNl;:;ll:'
.......''...;,ooc,,,:od'.':cccdd,,l''cl:co;;,..;;'..','..;d0O,;;:XXXK
............'cll;',,lo'.'.::codl,c..:c;doc.,:.',....'...'......'l0XKk
'............c;;,':lc.'',.;ccol;:,.:c.:o,;'.;'......,...',,.'...'.,;;
.............',;;,cc..;,'';:lc':;..c'.c:;.,......,'..'...'',:,,;;,...
..............',,;:'.';,',:c;.;;..';..,;,.........''..'...'kko.,,....
...............;,:'..;''';:,..;''.''..''............'...'.lK0c';;c;'.
...............,,'...,.',;''...''....,......'............'dOx',;:dd,'
..............',.....'.,;..'..',..........'..............';:;',,ldo.'
.............'''.'.....,'..',','..'...''..'............'.......,dx'.'
.......................,...';,'..'.....,.'.............''.'......'..'
...........'......'...',..'';,'..'.....................',';,..'....'.

GitHub

https://github.com/brianegan/chewie
Comments
  • 1. [Android] Add a delay before displaying progress indicator

    After a bit of digging in the video_player, I managed to enhance the seeking performance.

    However, with this when seeking, it's frequent to have dozen of milliseconds between STATE_BUFFERING and STATE_READY. This makes the CircularProgressIndicator be displayed during a few milliseconds.

    To prevent this, we propose to introduce a bit of temporization between the first isBuffering status and displaying the CircularProgressIndicator.

    | Proposal | Actual | | --- | --- | |chewie|schnell|

    Currently, an arbitrary timeout of 200ms has been chosen.

    Linked pull request : https://github.com/flutter/plugins/pull/5145

    NB: This proposal only edit the material_control version of the player. I can edit the other view if you are willing to accept this proposal.

    Reviewed by henri2h at 2022-04-01 16:19
  • 2. Because chewie >=1.2.0 depends on provider ^5.0.0

    Because chewie >=1.2.0 depends on provider ^5.0.0 and flutter_bloc >=7.2.0 depends on provider ^6.0.0, chewie >=1.2.0 is incompatible with flutter_bloc >=7.2.0. So, because baseflutter depends on both flutter_bloc ^7.3.0 and chewie ^1.2.2, version solving failed. pub get failed (1; So, because baseflutter depends on both flutter_bloc ^7.3.0 and chewie ^1.2.2, version solving failed.)

    Reviewed by VNAPNIC at 2021-12-07 07:08
  • 3. Error when setting autoPlay: false

    ════════ Exception caught by gesture ═══════════════════════════════════════════════════════════════ The following NoSuchMethodError was thrown while handling a gesture: The getter '_duration' was called on null. Receiver: null Tried calling: _duration

    When the exception was thrown, this was the stack: #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5) #1 Duration.>= (dart:core/duration.dart:173:63) #2 _CupertinoControlsState._playPause (package:chewie/src/cupertino_controls.dart:498:45) #3 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24) #4 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:365:11) ... Handler: "onTap" Recognizer: TapGestureRecognizer#d9726 debugOwner: GestureDetector state: ready won arena finalPosition: Offset(49.5, 619.5) finalLocalPosition: Offset(10.5, 18.5) sent tap down ════════════════════════════════════════════════════════════════════════════════════════════════════

    ════════ (2) Exception caught by gesture ═══════════════════════════════════════════════════════════ The getter '_duration' was called on null. Receiver: null Tried calling: _duration ════════════════════════════════════════════════════════════════════════════════════════════════════

    Reviewed by budo385 at 2019-11-04 22:35
  • 4. Correct AspectRatio Issue | Allow Portrait

    Thank you @brianegan and all other contributors for this great 📦

    I saw some bugs in the player_with_controls and corrected the AspectRatio issue with Portrait Mode and enabled Portrait as of correcting it.

    I tested it several times and now chewie is calculating the video aspect ratio correctly. Furthermore I am also able to set the custom aspectRatio in the parameter if needed. But due to this fix maybe it's useless for the future.

    Result (inScreen): Bildschirmfoto 2020-03-24 um 01 47 54

    Result (FullScreen): Bildschirmfoto 2020-03-24 um 01 58 57

    The problem in player_with_controls were:

    1. the _calculateAspectRatio only calculated AspectRatio related to the device and is setting it for the whole view: Video + Controls. But the AspectRatio from the video was never used.
    2. The Height was ignored in the Container so it was necessary to set it also to enable Portrait correctly.
    Reviewed by Ahmadre at 2020-03-24 00:49
  • 5. Dispose VideoPlayerController when Widget is disposed

    Prevents the video from still playing in the background, when ChewieWidget is disposed.

    Example: When I close the view containing the ChewieWidget, e.g. navigate somwhere, the audio can still be heard in the background, since the VideoPlayerController has not been disposed.

    Also includes the small Readme link fix from #75

    Reviewed by nstrelow at 2018-12-16 20:41
  • 6. List of video players

    Is there easy way to make list of video players? I want to show up more than 1 video. I tried this:

    void main() {
      runApp(
        new ChewieDemo(controller:[
           new VideoPlayerController('https://flutter.github.io/assets-for-api-docs/videos/butterfly.mp4'),
           new VideoPlayerController('https://flutter.github.io/assets-for-api-docs/videos/bee.mp4'),
        ]),
      );
    }
    
    class ChewieDemo extends StatefulWidget {
      final String title;
      final List <VideoPlayerController> controller;
    

    But widget.controller gives error with argument type List. Could you help me?

    Reviewed by vessivanov at 2018-02-15 12:04
  • 7. Remove iconic font for improved App Store compatibility

    Fixes #381 by removing the open_iconic_flutter dependency (which was bringing in the unsupported woff font file), replacing the icons with Cupertino (and Material, if appropriate) variants.

    While not a pixel for pixel replacement, they are like for like as the iconography is identical.

    Existing Iconic version: iconic

    Version of this PR, using Cupertino icons: cupertino

    Reviewed by erickok at 2020-10-27 10:09
  • 8. Add support for provider version 6

    Allows Provider version 6 to be used in conjunction with Chewie.

    Some libraries are starting to update to use v6 of provider (such as flutter_bloc: ^7.2.0) which throws the following error on pub get:

    Because no versions of chewie match >1.2.2 <2.0.0 and chewie 1.2.2 depends on provider ^5.0.0, chewie ^1.2.2 requires provider ^5.0.0.
    And because flutter_bloc >=7.2.0 depends on provider ^6.0.0, chewie ^1.2.2 is incompatible with flutter_bloc >=7.2.0.
    

    The breaking changes in the provider changelog only talk about optional providers of which Chewie doesn't use any so it should be safe to use provider 6 with chewie. Example app still appears to work as expected with provider v6. Have added <7 to safeguard against breaking changes in future unreleased versions of Provider.

    Closes #530

    Reviewed by zbarbuto at 2021-09-20 06:30
  • 9. Can we help maintaining?

    Hey, @brianegan . Awesome work on this package. So many people use it and it is just a must for a great video player experience in Flutter.

    Searching for chewie in pubspec.yaml on GitHub returns 1,308 results and that's only for GitHub. Very impressive!

    I noticed that there are a lot of PRs and Issues opened and there has not been a commit for 6 months now.

    Are you currently able to maintain this package? Can some people maybe pitch in and help out?

    Good luck on everything you got going on :D

    Reviewed by nstrelow at 2020-10-07 11:13
  • 10. error in streaming video, IOS (_duration is null)

    Error show in IOS for streaming video:

    The following NoSuchMethodError was thrown while handling a gesture: The getter '_duration' was called on null. Receiver: null Tried calling: _duration

    Option:

    _chewieController = ChewieController( videoPlayerController: _videoPlayerController1, aspectRatio: 3 / 2, autoPlay: false, looping: true, isLive: true,

    Regards

    Reviewed by numericni at 2020-09-13 19:51
  • 11. [notwork in fullscreen] auto play next src

    initPlayer() async {
       
        _videoPlayerController = VideoPlayerController.network(src);
        _videoPlayerController.addListener(autoNextLis);
    
        _chewieController = ChewieController(
          videoPlayerController: _videoPlayerController,
          aspectRatio: 16 / 9,
          autoPlay: true,
          looping: false,
          allowedScreenSleep: false,
          allowFullScreen: true,
          allowMuting: false,
        );
        setState(() {});
      }
    
     autoNextLis() {
        int total = _videoPlayerController.value.duration?.inMilliseconds;
        final int pos = _videoPlayerController.value.position?.inMilliseconds ?? 0;
    
        if (total == null) total = 1;
        if (total - pos <= 0) {
          _videoPlayerController.removeListener(autoNextLis);
          if (currPlayIndex + 1 < videoList.length) toggleVideo(currPlayIndex + 1);
        }
      }
    
     toggleVideo(int i) async {
        if (i == currPlayIndex ||
            i > videoList.length - 1 ||
            (!_videoPlayerController.value.initialized &&
                !_videoPlayerController.value.hasError)) return;
        await _videoPlayerController.pause();
        currPlayIndex = i;
        await initPlayer();
      }
    

    When the playback is finished, the next video is played, and the full-screen video is stopped, but the non-full-screen video is playing the next video (click back to see)!

    Reviewed by shiyiya at 2020-02-04 06:50
  • 12. Use another audio track in hls

    I want to use a different audio track when the video is playing. I have a link to the audio that I want to put on top, but it just doesn't run on top of chewie. Is it possible?

    Reviewed by Kerblif at 2022-06-18 20:16
  • 13. Is it possible to disable the subtitles by default?

    I've added subtitles and they work. I can disable them in the app manually, but is there a way to disable them in the code automatically (ideally as the default option)?

    Reviewed by JThorvid at 2022-06-17 18:51
  • 14. fullScreenByDefault: true triggers fullscreen twice

    fullScreenByDefault: true triggers the fullscreen again the first time you exit fullscreen. I'm using Navigator 2.0 (using Routemaster package) and maybe its related to #618. You can find a repo to reproduce the bug in this comment: https://github.com/fluttercommunity/chewie/issues/618#issuecomment-1156713212

    Reviewed by J-Dark at 2022-06-16 14:37
  • 15. [Question] How to play a multilingual movie?

    I have designed an application that I need to support multilingual movies (that means having a movie with two audios like English and French). How can I have this feature in this package?

    Reviewed by AhmadFalahian at 2022-06-07 12:14

Related

Flutter Music Player - A complete and open source music player designed in flutter.
 Flutter Music Player - A complete and open source music player designed in flutter.

Flutter Music Player A complete and open source music player designed in flutter. It is first complete music player designed in flutter. This app expl

Jun 28, 2022
Flutter-Music-Player - A simple music player app that let you play mp3 songs with some customization feature with a rich user interface
Flutter-Music-Player - A simple music player app that let you play mp3 songs with some customization feature with a rich user interface

Flutter-Music-Player - A simple music player app that let you play mp3 songs with some customization feature with a rich user interface

Feb 10, 2022
Better video player for Flutter, with multiple configuration options. Solving typical use cases!
Better video player for Flutter, with multiple configuration options. Solving typical use cases!

Better video player for Flutter, with multiple configuration options. Solving typical use cases!

Jun 20, 2022
Advanced video player based on video_player and Chewie for flutter
Advanced video player based on video_player and Chewie for flutter

Better Player Advanced video player based on video_player and Chewie. It's solves many typical use cases and it's easy to run. Introduction This plugi

Dec 22, 2021
This is a flutter package of video player. it's a very simple and easy to use.
This is a flutter package of video player. it's a very simple and easy to use.

This is a flutter package of video player. it's a very simple and easy to use.

Jun 26, 2022
Audio player app in Flutter. Created as a tutorial for learning Flutter.

Music Player: create a simple Flutter music player app This is a Flutter project used during a series of articles on I should go to sleep. License Cop

May 5, 2022
Flutter radio player mod flutter 2.5

A Flutter plugin to play streaming audio content with background support and lock screen controls.

Mar 14, 2022
Flutter plugin for sound. Audio recorder and player.
Flutter plugin for sound. Audio recorder and player.

Flutter Sound user: your documentation is there The CHANGELOG file is here Overview Flutter Sound is a Flutter package allowing you to play and record

Jun 28, 2022
BlackHole - A Music Player App made with Flutter
BlackHole - A Music Player App made with Flutter

BlackHole - A Music Player App made with Flutter

Jun 29, 2022
ZY Player TV app, developed with Flutter
ZY Player TV app, developed with Flutter

ZY-Player-TV ZY Player TV app, developed with Flutter 1. 设置Flutter环境 1.1 按着https://flutter.dev/docs/get-started/install/windows 页面的指导,先安装好Flutter和Andr

Jun 16, 2022
Enjoy podcasts with Tsacdop! A podcast player built with flutter.
Enjoy podcasts with Tsacdop!  A podcast player built with flutter.

About Enjoy podcasts with Tsacdop. Tsacdop is a podcast player developed with Flutter, a clean, simply beautiful and friendly app, which is also free

Jun 10, 2022
A Material designed music player developed in Flutter.
A Material designed music player developed in Flutter.

Flutter Music Player UI A Material designed music player developed in Flutter. Getting Started This project is a starting point for a Flutter applicat

Jan 13, 2022
Flutter plugin for sound. Audio recorder and player.
Flutter plugin for sound. Audio recorder and player.

Sounds Sounds is a Flutter package allowing you to play and record audio for both the android and ios platforms. Sounds provides both a high level API

May 5, 2022
Flutter music player application. (仿网易云音乐)
Flutter music player application. (仿网易云音乐)

Flutter music player application. (仿网易云音乐)

Jun 18, 2022
A Flutter music player to play songs (mp3).
A Flutter music player to play songs (mp3).

?? ?? Flutter Music A Flutter music player to play songs (mp3). Please star ⭐ the repo if you like what you see ?? . ?? Requirements Any Operating Sys

Jun 24, 2022
A simple music player made using Flutter.
A simple music player made using Flutter.

Music Player App This is a beautiful music player, developed using Flutter. Features Play any song included in Flutter Assets Background Play Beautifu

May 21, 2022
A flutter based music player for subsonic compatible music servers.
A flutter based music player for subsonic compatible music servers.

subsound A subsonic music player. Screenshots Release todo fix random breakage of player sometimes. seems like onStart is not working after background

May 20, 2022
A Music Player App made using Flutter.
A Music Player App made using Flutter.

A local music player app made using flutter. Getting Started This project is a starting point for a Flutter application. A few resources to get you st

Jun 13, 2022
A Sound Player App For Flutter
A Sound Player App For Flutter

sound_player_app A Sound Player Flutter application.

Jan 18, 2022