Git Product home page Git Product logo

chewie's Introduction

chewie

Flutter Community: 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!

Preview

MaterialControls MaterialDesktopControls

CupertinoControls

Installation

In your pubspec.yaml file within your Flutter Project add chewie and video_player under dependencies:

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

Using it

import 'package:chewie/chewie.dart';
final videoPlayerController = VideoPlayerController.networkUrl(Uri.parse(
    '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();
}

Options

Chewie has some options which control the video. These options appear by default in a showModalBottomSheet (similar to YT). By default, Chewie passes Playback speed and Subtitles options as an OptionItem.

To add additional options, just add these lines to your ChewieController:

additionalOptions: (context) {
  return <OptionItem>[
    OptionItem(
      onTap: () => debugPrint('My option works!'),
      iconData: Icons.chat,
      title: 'My localized title',
    ),
    OptionItem(
      onTap: () =>
          debugPrint('Another option that works!'),
      iconData: Icons.chat,
      title: 'Another localized title',
    ),
  ];
},

Customizing the modal sheet

If you don't like the default showModalBottomSheet for showing your options, you can override the View with the optionsBuilder method:

optionsBuilder: (context, defaultOptions) async {
  await showDialog<void>(
    context: context,
    builder: (ctx) {
      return AlertDialog(
        content: ListView.builder(
          itemCount: defaultOptions.length,
          itemBuilder: (_, i) => ActionChip(
            label: Text(defaultOptions[i].title),
            onPressed: () =>
                defaultOptions[i].onTap!(),
          ),
        ),
      );
    },
  );
},

Your additionalOptions are already included here (if you provided additionalOptions)!

Translations

What is an option without proper translation?

To add your translation strings add:

optionsTranslation: OptionsTranslation(
  playbackSpeedButtonText: 'Wiedergabegeschwindigkeit',
  subtitlesButtonText: 'Untertitel',
  cancelButtonText: 'Abbrechen',
),

Subtitles

Since version 1.1.0 chewie supports subtitles. Here you can see how to use them.

You can provide an List<Subtitle> and customize your subtitles with the subtitleBuilder function.

Add subtitles to your ChewieController like the following example:

ChewieController(
  videoPlayerController: _videoPlayerController,
  autoPlay: true,
  looping: true,
  subtitle: Subtitles([
    Subtitle(
      index: 0,
      start: Duration.zero,
      end: const Duration(seconds: 10),
      text: 'Hello from subtitles',
    ),
    Subtitle(
      index: 1,
      start: const Duration(seconds: 10),
      end: const Duration(seconds: 20),
      text: 'Whats up? :)',
    ),
  ]),
  subtitleBuilder: (context, subtitle) => Container(
    padding: const EdgeInsets.all(10.0),
    child: Text(
      subtitle,
      style: const TextStyle(color: Colors.white),
    ),
  ),
);

The index attribute is for if you want to structure your subtitles in your database and provide your indexes here. end and text are the key attributes.

The Duration defines which part of your video your subtitles should start and end. For example, if your video is 10 minutes long and you want to add a subtitle between: 00:00 and 00:10'th of a second:

Subtitle(
  index: 0,
  start: Duration.zero,
  end: const Duration(seconds: 10),
  text: 'Hello from subtitles',
),

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 later 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,
);

Roadmap

  • MaterialUI
  • MaterialDesktopUI
  • CupertinoUI
  • Options with translations
  • Subtitles
  • CustomControls
  • Auto-Rotate on FullScreen depending on Source Aspect-Ratio
  • Live-Stream and UI
  • AutoPlay
  • Placeholder
  • Looping
  • Start video at
  • Custom Progress-Bar colors
  • Custom Overlay
  • Allow Sleep (Wakelock)
  • Playbackspeed Control
  • Custom Route-Pagebuilder
  • Custom Device-Orientation and SystemOverlay before and after fullscreen
  • Custom ErrorBuilder
  • Support different resolutions of video
  • Re-design State-Manager with Provider
  • Screen-Mirroring / Casting (Google Chromecast)

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'.'
.......................,...';,'..'.....,.'.............''.'......'..'
...........'......'...',..'';,'..'.....................',';,..'....'.

chewie's People

Contributors

abhinandval avatar ahmadre avatar brianegan avatar buginrug avatar cbenhagen avatar creativecreatorormaybenot avatar daohoangson avatar diegotori avatar ekuleshov avatar erickok avatar hasanm08 avatar henri2h avatar jcquintas avatar jeremiahlukus avatar jweidner-mbible avatar koutaro-masaki avatar kronos-2701 avatar localpcguy avatar luis901101 avatar magaroo avatar maherjaafar avatar manikandn avatar mideb avatar milleradulu avatar nstrelow avatar pratik-7span avatar shakyacsun avatar shiyiya avatar toddzeil avatar ycv005 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chewie's Issues

video can not play on iOS device

this demo can run on android phone all right ,but can not play video on iOS devices. and notes that:Failed to load video:the operation could not completed

Video player throws error when put in ListView and scrolled past really quickly

When the video is part of a list and you scroll to it very quickly, it throws an error and the interface becomes red.

Code to reproduce:

import 'package:flutter/material.dart';
import 'package:chewie/chewie.dart';
import 'package:video_player/video_player.dart';


class Media extends StatefulWidget {
  @override
  MediaState createState() {
    return new MediaState();
  }
}

class MediaState extends State<Media> {
  VideoPlayerController _controller;


  @override
  void initState() {
    super.initState();
    _controller = new VideoPlayerController.network(
      'https://flutter.github.io/assets-for-api-docs/videos/butterfly.mp4',
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Media"),
        actions: <Widget>[],
      ),
      //TODO: Add a grid view (102)
      body: new ListView(
        children: <Widget>[
          Chewie(
            _controller,
            aspectRatio: 1280 / 720,
            autoPlay: false,
            looping: false,
          ),
          new Column(
            children: List.generate(20, (index) {
              return feedCard();
            }),
          ),
        ],
      ),
    );
  }

  Widget feedCard() {
    return new Card(
      child: new Column(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          ListTile(
            leading: Icon(Icons.ondemand_video),
            title: Text('The Enchanted Nightingale',
                style: TextStyle(fontWeight: FontWeight.bold)),
            subtitle: Column(
              children: <Widget>[
                Text('Video by Julie Gable. Lyrics by Sidney Stein.'),
                Align(
                  alignment: Alignment.bottomLeft,
                  child: Text('Sunday 5th July, 2020',
                      style: TextStyle(fontStyle: FontStyle.italic)),
                ),
              ],
            ),
          ),
          new ButtonTheme.bar(
            // make buttons use the appropriate styles for cards
            child: new ButtonBar(
              children: <Widget>[
                new FlatButton(
                  child: const Text('Download'),
                  onPressed: () {/* ... */},
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}

I/flutter ( 6193): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 6193): The following assertion was thrown building Chewie(state: _ChewiePlayerState#17748):
I/flutter ( 6193): A VideoPlayerController was used after being disposed.
I/flutter ( 6193): Once you have called dispose() on a VideoPlayerController, it can no longer be used.
I/flutter ( 6193): When the exception was thrown, this was the stack:
I/flutter ( 6193): #0      ChangeNotifier._debugAssertNotDisposed.<anonymous closure> (package:flutter/src/foundation/change_notifier.dart:61:9)
I/flutter ( 6193): #1      ChangeNotifier._debugAssertNotDisposed (package:flutter/src/foundation/change_notifier.dart:67:6)
I/flutter ( 6193): #2      ChangeNotifier.addListener (package:flutter/src/foundation/change_notifier.dart:97:12)
I/flutter ( 6193): #3      _VideoPlayerWithControlsState.initState (package:chewie/src/player_with_controls.dart:114:23)
I/flutter ( 6193): #4      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3751:58)
I/flutter ( 6193): #5      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3617:5)
I/flutter ( 6193): #6      Element.inflateWidget (package:flutter/src/widgets/framework.dart:2907:14)
I/flutter ( 6193): #7      Element.updateChild (package:flutter/src/widgets/framework.dart:2710:12)
I/flutter ( 6193): #8      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3653:16)
I/flutter ( 6193): #9      Element.rebuild (package:flutter/src/widgets/framework.dart:3495:5)
I/flutter ( 6193): #10     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3622:5)
I/flutter ( 6193): #11     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3769:11)
I/flutter ( 6193): #12     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3617:5)
I/flutter ( 6193): #13     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2907:14)
I/flutter ( 6193): #14     Element.updateChild (package:flutter/src/widgets/framework.dart:2710:12)
I/flutter ( 6193): #15     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4654:14)
I/flutter ( 6193): #16     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2907:14)
I/flutter ( 6193): #17     Element.updateChild (package:flutter/src/widgets/framework.dart:2710:12)
I/flutter ( 6193): #18     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3653:16)
I/flutter ( 6193): #19     Element.rebuild (package:flutter/src/widgets/framework.dart:3495:5)
I/flutter ( 6193): #20     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3622:5)
I/flutter ( 6193): #21     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3617:5)
I/flutter ( 6193): #22     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2907:14)
I/flutter ( 6193): #23     Element.updateChild (package:flutter/src/widgets/framework.dart:2710:12)
I/flutter ( 6193): #24     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3653:16)
I/flutter ( 6193): #25     Element.rebuild (package:flutter/src/widgets/framework.dart:3495:5)
I/flutter ( 6193): #26     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3622:5)
I/flutter ( 6193): #27     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3617:5)
I/flutter ( 6193): #28     ParentDataElement.mount (package:flutter/src/widgets/framework.dart:3955:11)
I/flutter ( 6193): #29     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2907:14)
I/flutter ( 6193): #30     Element.updateChild (package:flutter/src/widgets/framework.dart:2710:12)
I/flutter ( 6193): #31     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3653:16)
I/flutter ( 6193): #32     Element.rebuild (package:flutter/src/widgets/framework.dart:3495:5)
I/flutter ( 6193): #33     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3622:5)
I/flutter ( 6193): #34     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3769:11)
I/flutter ( 6193): #35     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3617:5)
I/flutter ( 6193): #36     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2907:14)
I/flutter ( 6193): #37     Element.updateChild (package:flutter/src/widgets/framework.dart:2710:12)
I/flutter ( 6193): #38     SliverMultiBoxAdaptorElement.updateChild (package:flutter/src/widgets/sliver.dart:744:36)
I/flutter ( 6193): #39     SliverMultiBoxAdaptorElement.createChild.<anonymous closure> (package:flutter/src/widgets/sliver.dart:729:20)
I/flutter ( 6193): #40     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2222:19)
I/flutter ( 6193): #41     SliverMultiBoxAdaptorElement.createChild (package:flutter/src/widgets/sliver.dart:722:11)
I/flutter ( 6193): #42     RenderSliverMultiBoxAdaptor._createOrObtainChild.<anonymous closure> (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:254:23)
I/flutter ( 6193): #43     RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1666:58)
I/flutter ( 6193): #44     PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:740:15)
I/flutter ( 6193): #45     RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1666:13)
I/flutter ( 6193): #46     RenderSliverMultiBoxAdaptor._createOrObtainChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:243:5)
I/flutter ( 6193): #47     RenderSliverMultiBoxAdaptor.insertAndLayoutLeadingChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:352:5)
I/flutter ( 6193): #48     RenderSliverList.performLayout (package:flutter/src/rendering/sliver_list.dart:99:29)
I/flutter ( 6193): #49     RenderObject.layout (package:flutter/src/rendering/object.dart:1570:7)
I/flutter ( 6193): #50     RenderSliverPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:182:11)
I/flutter ( 6193): #51     RenderObject.layout (package:flutter/src/rendering/object.dart:1570:7)
I/flutter ( 6193): #52     RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:336:13)
I/flutter ( 6193): #53     RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1131:12)
I/flutter ( 6193): #54     RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1049:20)
I/flutter ( 6193): #55     RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1445:7)
I/flutter ( 6193): #56     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:709:18)
I/flutter ( 6193): #57     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:270:19)
I/flutter ( 6193): #58     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:627:13)
I/flutter ( 6193): #59     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:208:5)
I/flutter ( 6193): #60     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter ( 6193): #61     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter ( 6193): #62     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
I/flutter ( 6193): #63     _invoke (dart:ui/hooks.dart:120:13)
I/flutter ( 6193): #64     _drawFrame (dart:ui/hooks.dart:109:3)

Some vids only work in Full Screen

Reported via email:

I love this package, however I have had an issue where some links only work in fullscreen mode. I'm testing on an android.

Links such as this work fine with the video player plugin but not in chewie. When I hit play the UI disappears and then when I can accidentally tap where the fullscreen should be the video will work in fullscreen mode.

https://i.imgur.com/TKL8h8J.mp4

How to implement onVideoCompletion Callback ?? Help Required

After watch video I have to mark it watched so I need a onCompletion Callback. I tried with listener as `class _ChewieDemoState extends State {
TargetPlatform _platform;
VideoPlayerController _controller;
VoidCallback listener;
bool isCompeleted = false;

@OverRide
void initState() {
super.initState();
_controller = new VideoPlayerController.network(
'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerEscapes.mp4',
);
listener = () {
// if (!mounted) {
// return;
// }
//debugPrint("listening .....");

  if(_controller.value.duration!=null){
    debugPrint("duration"+_controller.value.duration.inMilliseconds.toString()+" _ position _"+"duration"+_controller.value.position.inMilliseconds.toString());
    //debugPrint(_controller.value.position.inMilliseconds.toString());
    if(_controller.value.duration.inMilliseconds==_controller.value.position.inMilliseconds){
      debugPrint("competed .....");
      _controller.removeListener(listener);
    }

  }

// if (isCompeleted == _controller.value.completed) {
// initialized = _controller.value.initialized;
// setState(() {});
// }
};
_controller.addListener(listener);

}`

But it don't work and _controller.value.duration.inMilliseconds and _controller.value.position.inMilliseconds never become same ,quite surprising why ? Thanks in advance

Fullscreen events

Hello, is there any way to access the events when the video comes out of full screen?
Because my application runs in full screen and leaves it when I leave a video in full screen.
I need my application to return to full screen.
Thanks!
Sorry for my english.

Use of the VideoPlayerController inside Chewie

I have two questions about chewie (which are tecnically speaking not 'issues') that i feel like would not make sense on github or gitter because of their specific nature. It would be great if you could help me out here! :)

That said, my current structure is simplified the following

new FutureBuilder<DocumentSnapshot>(
...
new Chewie(
	controller,
	aspectRatio: 16 / 9,
	autoPlay: true,
	looping: false,
	placeholder: new Container(
	color: Colors.grey,
	),
	autoInitialize: true,
),
),
...
  @override
  void initState() {
    controller = new VideoPlayerController(
        'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.mp4');

    super.initState();
  }

As seen above, the controller is outsiede the scope of the Futurebuilder, so no data from the DocumentSnapshot can be used as a parameter for the VideoPlayerController.

So now my question: is it possible to implement the VideoPlayerController inside the Chewie widget, or can I maybe pass a value from the FutureBuilder down to the VideoPlayerController any other way? Any help would be highly appreciated!

On a sidenote, do you know whether it is possible to rotate the currently watched video into landscape mode as soon as the Fullscreen mode is activated? This way more screen real estate would be used and the user would be incentivised to rotate his/her device.

RTMP Player

Hi! I need to play an RTMP stream (I don't want to use hls) but I don't find the way for doing that. How I can play it with Flutter?

Thanks!

chewie does not respect previous UI orientation

When chewie enters Fullscreen mode, it set the preferred Orientation to landscape mode.
when you exits fullscree, chewie sets the preferred orientation ot portrait as well as landscape.

It is fine to have landscape mode for the video, but if you had your app set to portrait mode only before, after leaving fullscreen video mode, the app will be available in landscape mode again, which might not be intended.

chewie should respect the previous orientation mode.

local video

new VideoPlayerController.asset(
      "assets/videos/test.mp4",

local videos crash...

Fullscreen mode by default

Hello.

I am trying to figure out how to load a video in fullscreen mode by default.
How would you do it?
Thanks in advance.

Buffering event and listener

I am pretty impressed with this player and have started using it already, however I don't see how I can implement the circle indicator when the video is buffering. I mean, there's no callback property as such where I can use a stack to show/hide indicator on top.

Full Screen: Use Landscape mode

When transitioning to Full screen, we should force screen rotation and use the entire size of the screen, at least on Android (need to check what iOS does here).

Update Video_player

Hi can you update video_player to as there is an issue with IOS in the 0.6.4 version and using Chewie always loads the 0.6.4 version.
video_player: git: url: https://github.com/recastrodiaz/plugins.git path: packages/video_player ref: f0ade3cf3e366ec1e93139458f2bdf32d243b2be version: ^0.6.5

updated video player 0.7.5

has Exception

I/dalvikvm( 5366): Could not find method android.graphics.SurfaceTexture.setOnFrameAvailableListener, referenced from method io.flutter.view.FlutterView$SurfaceTextureRegistryEntry.
W/dalvikvm( 5366): VFY: unable to resolve virtual method 697: Landroid/graphics/SurfaceTexture;.setOnFrameAvailableListener (Landroid/graphics/SurfaceTexture$OnFrameAvailableListener;Landroid/os/Handler;)V
D/dalvikvm( 5366): VFY: replacing opcode 0x6e at 0x0015
E/flutter ( 5366): [ERROR:flutter/shell/platform/android/platform_view_android_jni.cc(40)] java.lang.NoSuchMethodError: android.graphics.SurfaceTexture.setOnFrameAvailableListener
E/flutter ( 5366): at io.flutter.view.FlutterView$SurfaceTextureRegistryEntry.(FlutterView.java:969)
E/flutter ( 5366): at io.flutter.view.FlutterView.createSurfaceTexture(FlutterView.java:955)
E/flutter ( 5366): at io.flutter.plugins.videoplayer.VideoPlayerPlugin.onMethodCall(VideoPlayerPlugin.java:291)
E/flutter ( 5366): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:191)
E/flutter ( 5366): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163)
E/flutter ( 5366): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter ( 5366): at android.os.MessageQueue.next(MessageQueue.java:138)
E/flutter ( 5366): at android.os.Looper.loop(Looper.java:150)
E/flutter ( 5366): at android.app.ActivityThread.main(ActivityThread.java:5323)
E/flutter ( 5366): at java.lang.reflect.Method.invokeNative(Native Method)
E/flutter ( 5366): at java.lang.reflect.Method.invoke(Method.java:515)
E/flutter ( 5366): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
E/flutter ( 5366): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
E/flutter ( 5366): at dalvik.system.NativeStart.main(Native Method)
E/flutter ( 5366):
F/flutter ( 5366): [FATAL:flutter/shell/platform/android/platform_view_android_jni.cc(77)] Check failed: CheckException(env).
F/libc ( 5366): Fatal signal 6 (SIGABRT) at 0x000014f6 (code=-6), thread 5366 (ive.mysterylive)
handle_request(15)

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?

Fullscreen aspect ratio

Hi!
When switching fullscreen the aspect ratio is not respected, the video is always strechted to the size of the screen

If the videoplayer is wrapped in a AspectRatio also with the condition "widget.fullScreen && MediaQuery.of(context).orientation == Orientation.landscape" in "player_with_controls.dart" then the aspect ratio seems to be preserved

Thank you!

Fullscreen on landsacpe

It would be nice if the player could automatically switch to fullscreen mode when the device is currently in (or when being rotated to) landscape mode.

videoplayer has error com.google.android.exoplayer2 ExoPlaybackException

My video prompts an error when playing repeatedly. The position of the progress bar.
image
It's normal at the beginning, and I will have this problem when I open the video frequently.

I/ExoPlayerImpl(22488): Release a840477 [ExoPlayerLib/2.8.0] [HWRNE, RNE-L22, HUAWEI, 26] [goog.exo.core]

E/ExoPlayerImplInternal(22488): Caused by: android.media.MediaCodec$CodecException: start failed
E/ExoPlayerImplInternal(22488): at android.media.MediaCodec.native_start(Native Method)
E/ExoPlayerImplInternal(22488): at android.media.MediaCodec.start(MediaCodec.java:2063)
E/ExoPlayerImplInternal(22488): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:421)
E/ExoPlayerImplInternal(22488): ... 8 more
E/ExoPlayerImplInternal(22488): Stop failed.

Strange size issue

@brianegan do you see a reason why 1px of the video can be seen on the left side? This does not happen if use the VideoPlayer.

screenshot_1530200866

bildschirmfoto 2018-06-28 um 17 53 38

import 'package:chewie/chewie.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';

void main() {
  runApp(
    ChewieDemo(),
  );
}

class ChewieDemo extends StatefulWidget {
  final String title;

  ChewieDemo({this.title = 'Chewie Demo'});

  @override
  State<StatefulWidget> createState() {
    return _ChewieDemoState();
  }
}

class _ChewieDemoState extends State<ChewieDemo> {
  TargetPlatform _platform;
  VideoPlayerController _controller;

  @override
  void initState() {
    super.initState();
    _controller = VideoPlayerController.network(
      'https://flutter.github.io/assets-for-api-docs/videos/butterfly.mp4',
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: widget.title,
      theme: ThemeData.light().copyWith(
            platform: _platform ?? Theme.of(context).platform,
          ),
      home: Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: Padding(
          padding: EdgeInsets.all(20.0),
          child: Stack(
            children: [
              Chewie(
                _controller,
                autoPlay: true,
                looping: true,
              ),
              Container(color: Colors.white),
            ],
          ),
        ),
      ),
    );
  }
}

Hide play button until video has loaded

With a network video, sometimes the video can take a couple seconds to load. The play button still shows up during this time and the user can press it. I can use a placeholder to show a CircularProgressIndicator but the play button sits in front of it, hiding it.

It would be great if the play button was hidden until the video had finished loading/initializing.

not competitive with video_player version

Hello.
Your lib not working in newest video_player version, plz update it. Thanks you
Because chewie 0.3.0 depends on video_player ^0.2.0 and no versions of chewie match >0.3.0 <0.4.0, chewie ^0.3.0 requires video_player ^0.2.0.
So, because icamerasolution depends on both video_player ^0.5.3 and chewie ^0.3.0, version solving failed.
pub get failed (1)

Get onClickListener for play button.

Am new to flutter and dart.
Is there any delegate method or any OnClickListener method when tapping play button.
On Pressed of floating button is not working properly.
I tried to add Gesture too.

import 'package:chewie/chewie.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
import 'package:flutter/services.dart';



class ChewieDemo extends StatefulWidget {
  final String title;

  ChewieDemo({this.title = 'Chewie Demo'});

  @override
  _ChewieDemoState createState() => new _ChewieDemoState();
}

class _ChewieDemoState extends State<ChewieDemo> {
  TargetPlatform _platform = TargetPlatform.android;
  VideoPlayerController _controller;




  @override
  void initState() {
    super.initState();
    _platform = TargetPlatform.android;
    _controller = new VideoPlayerController.network(
      'https://flutter.github.io/assets-for-api-docs/videos/butterfly.mp4',
    );

  }

  @override
  void didUpdateWidget(ChewieDemo oldWidget) {
    print("didUpdateWidget");
    new SimpleDialog(
      title: const Text('Select assignment'),
      children: <Widget>[
        new SimpleDialogOption(
          onPressed: () {
            //  Navigator.pop(context, Department.treasury);
          },
          child: const Text('Treasury department'),
        ),
        new SimpleDialogOption(
          onPressed: () {
            //Navigator.pop(context, Department.state);
          },
          child: const Text('State department'),
        ),
      ],
    );
    // TODO: implement didUpdateWidget
    super.didUpdateWidget(oldWidget);
  }

  @override
  Widget build(BuildContext context) {
    double width = MediaQuery.of(context).size.width;
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body: new Column(
        children: <Widget>[
          new Chewie(
            _controller,
            aspectRatio: 3 / 2,
            autoPlay: false,
            looping: true,
            autoInitialize: true,
            materialProgressColors: new ChewieProgressColors(
              playedColor: Colors.red,
              handleColor: Colors.blue,
              backgroundColor: Colors.grey,
              bufferedColor: Colors.lightGreen,
            ),
          ),
        ],
      ),
      floatingActionButton: new FloatingActionButton(
        onPressed:
            _controller.value.isPlaying ? _controller.pause : _controller.play,
        child: new Icon(
          _controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
        ),
      ),
    );
  }
}

Help: CoMaintainer needed!

Hey all! I've been getting more and more issues on this library, but don't have a much time to work on Chewie at the moment. I'm looking for someone who is willing to help maintain Chewie so we can help support folks and fix bugs at a faster rate!

If you're interested, please respond to this issue and we'll go from there :)

Buffering UI

If the video is buffering but not playing, show some UI to let the user know. Currently, there isn't much info coming back from the Controller of when the video is in this state. Need to find a way to determine this.

Isuue with VideoPlayerController

compiler message: lib/main.dart:67:9: Error: Method not found: 'VideoPlayerController'.
compiler message:     new VideoPlayerController(
compiler message:         ^^^^^^^^^^^^^^^^^^^^^
  final playerWidget = new Chewie(

    new VideoPlayerController(
        'https://flutter.github.io/assets-for-api-docs/videos/butterfly.mp4'
    ),
    aspectRatio: 3 / 2,
    autoPlay: true,
    looping: true,
  );

Fade between placeholder and first video frame

Right now it goes from placeholder to black to first frame which looks pretty crappy. Maybe we can't do much about the first frame being black but fading would at least make the experience a lot smoother.

Better Cupertino Icons

Looks like the Flutter team has some Cupertino icons in a font, but does not expose all of them yet. Watch for updates to the Flutter repo and use the better icons when available.

ios don't support m3u8

cupertino_controls.dart and material_controls.dart need to update .please tell me how to do...

Two parameters not defined after flutter packer upgrade

After the use of Flutter Packages upgrade the parameters handleColor and disabledColor of progressColors: new VideoProgressColors(..) are not defined, although they are described in the example as "Try playing around with some of these other options".
Are they simply no longer necessary or is this a bug? Thanks anyway for the awesome chewie package!

Video doesn't play in full screen

Hi,
I have an issue when I click the icon to play in full screen.
It shows a play button but it doesn't work and when I click back I can see the error on the screen and console.

I'm copying the erro in case I'm missing something

I/ViewRootImpl(21950): ViewRoot's Touch Event : ACTION_DOWN I/ViewRootImpl(21950): ViewRoot's Touch Event : ACTION_UP E/flutter (21950): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception: E/flutter (21950): A VideoPlayerController was used after being disposed. E/flutter (21950): Once you have called dispose() on a VideoPlayerController, it can no longer be used. E/flutter (21950): #0 ChangeNotifier._debugAssertNotDisposed.<anonymous closure> (package:flutter/src/foundation/change_notifier.dart:61:9) E/flutter (21950): #1 ChangeNotifier._debugAssertNotDisposed (package:flutter/src/foundation/change_notifier.dart:67:6) E/flutter (21950): #2 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:155:12) E/flutter (21950): #3 ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:217:5) E/flutter (21950): #4 VideoPlayerController.play (package:video_player/video_player.dart:223:5) E/flutter (21950): <asynchronous suspension> E/flutter (21950): #5 _MaterialControlsState._playPause.<anonymous closure> (package:chewie/src/material_controls.dart:288:29) E/flutter (21950): #6 State.setState (package:flutter/src/widgets/framework.dart:1125:30) E/flutter (21950): #7 _MaterialControlsState._playPause (package:chewie/src/material_controls.dart:275:5) E/flutter (21950): #8 _MaterialControlsState._buildHitArea.<anonymous closure> (package:chewie/src/material_controls.dart:122:17) E/flutter (21950): #9 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24) E/flutter (21950): #10 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:161:9) E/flutter (21950): #11 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:94:7) E/flutter (21950): #12 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9) E/flutter (21950): #13 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12) E/flutter (21950): #14 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11) E/flutter (21950): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:143:19) E/flutter (21950): #16 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22) E/flutter (21950): #17 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7) E/flutter (21950): #18 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64:7) E/flutter (21950): #19 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48:7) E/flutter (21950): #20 _invoke1 (dart:ui/hooks.dart:134:13) E/flutter (21950): #21 _dispatchPointerDataPacket (dart:ui/hooks.dart:91:5)

Regards

Feature Request: Hide video box when media is audio only

Chewie does a great job handling audio-only files; however, there should be a way to make chewie disable the video display box when media is an audio-only file.

This could be implemented as a flag to the chewie constructor so that only the audio controls are shown or so that no controls are shown at all.

I'll see if I can implement it myself and issue a pull request.

Controller '.dispose' explicit call never works

I am trying to play multiple videos one after the other by clicking thumbnails. More like a youtube kinda flow. I am aware to stop current video from playing (as I have to open the different video) I have to use following.
videoController.pause()
videoController.dispose()

These don't work, and the old video keeps playing in background after opening new video.

I also tried
@override void dispose() { videoController.dispose(); super.dispose(); }

in the main life cycle.

Can't play m3u8

Can't play m3u8 ? When can I update support for video_player version 0.5.3 or later?

Launch video in fullscreen through a custom button.

Hello,
I wanted to hide the video controls and alternatively launch the video in fullscreen when the user clicks on a specific button. I know that you can hide the controls through showControls attribute but I was wondering if there was anything to change the video to fullscreen. I do not think that the video_player plugin has anything of such functionality either although it does have a setVolume property which is missing in chewie. I was hoping if you knew anything about setting the video to fullscreen without relying on the video controls or could create such functionality.
Thank You.

Hide or disable progress bar

Hello, how can I hide the progress bar, since I'm streaming live video and dont need it.
I have commented "_buildPosition" and "_buildProgressBar" but It'st really hacky and mess with controls distribution.

Could you add that feature?
Thank you.

onCompletionListener callback

Hi.

In the current state of the plugin is it possible to set a callback function to be called on finished video playing? The listener for VideoPlayerController does not seem to help a lot. I tried to make it somehow work, but it is not always called in Android.

Chewie not render video when change controller

I have a problem with chewie. When I change the controller, chewie play the audio but not show the video. If I click on fullscreen and after, go back, the video is show correctly.
I have tried in Android v5.0 and emulator. the code is the same of the example.

import 'package:chewie/chewie.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';

void main() {
  runApp(
    new ChewieDemo(),
  );
}

class ChewieDemo extends StatefulWidget {
  final String title;

  ChewieDemo({this.title = 'Chewie Demo'});

  @override
  State<StatefulWidget> createState() {
    return new _ChewieDemoState();
  }
}

class _ChewieDemoState extends State<ChewieDemo> {
  TargetPlatform _platform;
  VideoPlayerController _controller;

  @override
  void initState() {
    super.initState();
    _controller = new VideoPlayerController.network(
      'https://github.com/flutter/assets-for-api-docs/blob/master/assets/videos/butterfly.mp4?raw=true',
    );
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: widget.title,
      theme: new ThemeData.light().copyWith(
        platform: _platform ?? Theme.of(context).platform,
      ),
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text(widget.title),
        ),
        body: new Column(
          children: <Widget>[
            new Expanded(
              child: new Center(
                child: new Chewie(
                  _controller,
                  aspectRatio: 3 / 2,
                  autoPlay: true,
                  looping: true,

                  // Try playing around with some of these other options:

                  // showControls: false,
                  // materialProgressColors: new ChewieProgressColors(
                  //   playedColor: Colors.red,
                  //   handleColor: Colors.blue,
                  //   backgroundColor: Colors.grey,
                  //   bufferedColor: Colors.lightGreen,
                  // ),
                  // placeholder: new Container(
                  //   color: Colors.grey,
                  // ),
                  // autoInitialize: true,
                ),
              ),
            ),
            new Row(
              children: <Widget>[
                new Expanded(
                  child: new FlatButton(
                    onPressed: () {
                      setState(() {
                        _controller = new VideoPlayerController.network(
                          'https://flutter.github.io/assets-for-api-docs/videos/butterfly.mp4',
                        );
                      });
                    },
                    child: new Padding(
                      child: new Text("Video 1"),
                      padding: new EdgeInsets.symmetric(vertical: 16.0),
                    ),
                  ),
                ),
                new Expanded(
                  child: new FlatButton(
                    onPressed: () {
                      setState(() {
                        _controller = new VideoPlayerController.network(
                          'http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_20mb.mp4',
                        );
                      });
                    },
                    child: new Padding(
                      padding: new EdgeInsets.symmetric(vertical: 16.0),
                      child: new Text("Video 2"),
                    ),
                  ),
                )
              ],
            ),
            new Row(
              children: <Widget>[
                new Expanded(
                  child: new FlatButton(
                    onPressed: () {
                      setState(() {
                        _platform = TargetPlatform.android;
                      });
                    },
                    child: new Padding(
                      child: new Text("Android controls"),
                      padding: new EdgeInsets.symmetric(vertical: 16.0),
                    ),
                  ),
                ),
                new Expanded(
                  child: new FlatButton(
                    onPressed: () {
                      setState(() {
                        _platform = TargetPlatform.iOS;
                      });
                    },
                    child: new Padding(
                      padding: new EdgeInsets.symmetric(vertical: 16.0),
                      child: new Text("iOS controls"),
                    ),
                  ),
                )
              ],
            )
          ],
        ),
      ),
    );
  }
}

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.