Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ext_video_player for Youtube support #619

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

* ⬆️ Update 'provider' to 6.0.1
- fixes [#568](https://github.com/brianegan/chewie/issues/568)
* ⬆️ Update 'video_player' to 2.2.7
* ⬆️ Update 'ext_video_player' to 2.2.7
* ⬆️ Update 'wakelock' to 0.5.6
* ⬆️ Update 'lint' to 1.7.2
* ⬆️ Update roadmap
Expand All @@ -54,7 +54,7 @@

* 💡 add `showOptions` flag to show/hide the options-menu
- Fixes: [#491](https://github.com/brianegan/chewie/issues/491)
* ⬆️ update `video_player` to 2.1.5
* ⬆️ update `ext_video_player` to 2.1.5
* 🛠️ fix MaterialUI duration text (RichText)

## 1.2.0
Expand Down Expand Up @@ -135,7 +135,7 @@

## 0.10.1

* Update `video_player` dependecy (stable release)
* Update `ext_video_player` dependecy (stable release)

## 0.10.0

Expand Down Expand Up @@ -168,7 +168,7 @@

## 0.9.6

* Update to work with `video_player: ">=0.7.0 <0.11.0"`
* Update to work with `ext_video_player: ">=0.7.0 <0.11.0"`

## 0.9.5

Expand All @@ -177,7 +177,7 @@
## 0.9.4

* Add overlay option to place a widget between the video and the controls
* Update to work with `video_player: ">=0.7.0 <0.10.0"`
* Update to work with `ext_video_player: ">=0.7.0 <0.10.0"`

## 0.9.3

Expand All @@ -199,7 +199,7 @@

## 0.8.0

* Update to work with `video_player: ">=0.7.0 <0.8.0` - Thanks @Sub6Resources
* Update to work with `ext_video_player: ">=0.7.0 <0.8.0` - Thanks @Sub6Resources
* Preserves AspectRatio on FullScreen - Thanks @patrickb
* Ability to start video in FullScreen - Thanks @miguelpruivo

Expand All @@ -217,19 +217,19 @@

## 0.6.0

* Update to work with `video_player: ">=0.6.0 <0.7.0`
* Update to work with `ext_video_player: ">=0.6.0 <0.7.0`

## 0.5.1

* Update README to fix installation instructions

## 0.5.0

* Update to work with `video_player: ">=0.5.0 <0.6.0`
* Update to work with `ext_video_player: ">=0.5.0 <0.6.0`

## 0.3.0

* Update to work with `video_player: ">=0.2.0 <0.3.0`
* Update to work with `ext_video_player: ">=0.2.0 <0.3.0`
* Add `showControls` option. You can use this to show / hide the controls
* Move from `VideoProgressColors` to `ChewieProgressColors` for customization of the Chewie progress controls
* Remove `progressColors` in favor of platform-specific customizations: `cupertinoProgressColors` and `materialProgressColors` to control
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

The video player for Flutter with a heart of gold.

The [`video_player`](https://pub.dartlang.org/packages/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!
The [`ext_video_player`](https://pub.dartlang.org/packages/ext_video_player) plugin provides low-level access to video playback. Chewie uses the `ext_video_player` under the hood and wraps it in a friendly Material or Cupertino UI!

## Preview

| MaterialControls | MaterialDesktopControls |
| :--------------: | :---------------------: |
| ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialControls.png) | ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialDesktopControls.png) |
| MaterialControls | MaterialDesktopControls |
| :-----------------------------------------------------------------------------: | :------------------------------------------------------------------------------------: |
| ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialControls.png) | ![](https://github.com/brianegan/chewie/raw/master/assets/MaterialDesktopControls.png) |

### CupertinoControls
![](https://github.com/brianegan/chewie/raw/master/assets/CupertinoControls.png)
Expand All @@ -23,7 +23,7 @@ In your `pubspec.yaml` file within your Flutter Project:
```yaml
dependencies:
chewie: <latest_version>
video_player: <latest_version>
ext_video_player: <latest_version>
```

## Use it
Expand Down Expand Up @@ -222,7 +222,7 @@ final playerWidget = Chewie(


## 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`
The ext_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](https://github.com/flutter/flutter/issues/14647).


Expand Down
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ linter:
close_sinks: true
sort_constructors_first: true
sort_pub_dependencies: false
depend_on_referenced_packages: false
1 change: 1 addition & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ linter:
rules:
close_sinks: true
sort_constructors_first: true
depend_on_referenced_packages: false
5 changes: 2 additions & 3 deletions example/lib/app/app.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'package:chewie/chewie.dart';
import 'package:chewie_example/app/theme.dart';
import 'package:ext_video_player/ext_video_player.dart';
import 'package:flutter/material.dart';
// ignore: depend_on_referenced_packages
import 'package:video_player/video_player.dart';

class ChewieDemo extends StatefulWidget {
const ChewieDemo({
Expand Down Expand Up @@ -174,7 +173,7 @@ class _ChewieDemoState extends State<ChewieDemo> {
child: Center(
child: _chewieController != null &&
_chewieController!
.videoPlayerController.value.isInitialized
.videoPlayerController.value.initialized
? Chewie(
controller: _chewieController!,
)
Expand Down
13 changes: 7 additions & 6 deletions lib/src/chewie_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import 'package:chewie/src/models/options_translation.dart';
import 'package:chewie/src/models/subtitle_model.dart';
import 'package:chewie/src/notifiers/player_notifier.dart';
import 'package:chewie/src/player_with_controls.dart';
import 'package:ext_video_player/ext_video_player.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:video_player/video_player.dart';
import 'package:wakelock/wakelock.dart';

typedef ChewieRoutePageBuilder = Widget Function(
Expand All @@ -21,7 +21,7 @@ typedef ChewieRoutePageBuilder = Widget Function(

/// A Video Player with Material and Cupertino skins.
///
/// `video_player` is pretty low level. Chewie wraps it in a friendly skin to
/// `ext_video_player` is pretty low level. Chewie wraps it in a friendly skin to
/// make it easy to use!
class Chewie extends StatefulWidget {
const Chewie({
Expand Down Expand Up @@ -182,9 +182,10 @@ class ChewieState extends State<Chewie> {
}

void onEnterFullScreen() {
final videoWidth = widget.controller.videoPlayerController.value.size.width;
final videoWidth =
widget.controller.videoPlayerController.value.size!.width;
final videoHeight =
widget.controller.videoPlayerController.value.size.height;
widget.controller.videoPlayerController.value.size!.height;

SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);

Expand Down Expand Up @@ -522,7 +523,7 @@ class ChewieController extends ChangeNotifier {
await videoPlayerController.setLooping(looping);

if ((autoInitialize || autoPlay) &&
!videoPlayerController.value.isInitialized) {
!videoPlayerController.value.initialized) {
await videoPlayerController.initialize();
}

Expand All @@ -535,7 +536,7 @@ class ChewieController extends ChangeNotifier {
}

if (startAt != null) {
await videoPlayerController.seekTo(startAt!);
await videoPlayerController.seekTo(startAt);
}

if (fullScreenByDefault) {
Expand Down
12 changes: 6 additions & 6 deletions lib/src/cupertino/cupertino_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import 'package:chewie/src/helpers/utils.dart';
import 'package:chewie/src/models/option_item.dart';
import 'package:chewie/src/models/subtitle_model.dart';
import 'package:chewie/src/notifiers/index.dart';
import 'package:ext_video_player/ext_video_player.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:video_player/video_player.dart';

class CupertinoControls extends StatefulWidget {
const CupertinoControls({
Expand Down Expand Up @@ -343,7 +343,7 @@ class _CupertinoControlsState extends State<CupertinoControls>
}

Widget _buildHitArea() {
final bool isFinished = _latestValue.position >= _latestValue.duration;
final bool isFinished = _latestValue.position >= _latestValue.duration!;
final bool showPlayButton =
widget.showPlayButton && !_latestValue.isPlaying && !_dragging;

Expand Down Expand Up @@ -452,7 +452,7 @@ class _CupertinoControlsState extends State<CupertinoControls>
}

Widget _buildRemaining(Color iconColor) {
final position = _latestValue.duration - _latestValue.position;
final position = _latestValue.duration! - _latestValue.position;

return Padding(
padding: const EdgeInsets.only(right: 12.0),
Expand Down Expand Up @@ -718,7 +718,7 @@ class _CupertinoControlsState extends State<CupertinoControls>
}

void _playPause() {
final isFinished = _latestValue.position >= _latestValue.duration;
final isFinished = _latestValue.position >= _latestValue.duration!;

setState(() {
if (controller.value.isPlaying) {
Expand All @@ -728,7 +728,7 @@ class _CupertinoControlsState extends State<CupertinoControls>
} else {
_cancelAndRestartTimer();

if (!controller.value.isInitialized) {
if (!controller.value.initialized) {
controller.initialize().then((_) {
controller.play();
});
Expand All @@ -752,7 +752,7 @@ class _CupertinoControlsState extends State<CupertinoControls>

void _skipForward() {
_cancelAndRestartTimer();
final end = _latestValue.duration.inMilliseconds;
final end = _latestValue.duration!.inMilliseconds;
final skip =
(_latestValue.position + const Duration(seconds: 15)).inMilliseconds;
controller.seekTo(Duration(milliseconds: math.min(skip, end)));
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cupertino/cupertino_progress_bar.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:chewie/src/chewie_progress_colors.dart';
import 'package:chewie/src/progress_bar.dart';
import 'package:ext_video_player/ext_video_player.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:video_player/video_player.dart';

class CupertinoVideoProgressBar extends StatelessWidget {
CupertinoVideoProgressBar(
Expand Down
10 changes: 5 additions & 5 deletions lib/src/material/material_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import 'package:chewie/src/material/widgets/playback_speed_dialog.dart';
import 'package:chewie/src/models/option_item.dart';
import 'package:chewie/src/models/subtitle_model.dart';
import 'package:chewie/src/notifiers/index.dart';
import 'package:ext_video_player/ext_video_player.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:video_player/video_player.dart';

class MaterialControls extends StatefulWidget {
const MaterialControls({
Expand Down Expand Up @@ -360,7 +360,7 @@ class _MaterialControlsState extends State<MaterialControls>
}

Widget _buildHitArea() {
final bool isFinished = _latestValue.position >= _latestValue.duration;
final bool isFinished = _latestValue.position >= _latestValue.duration!;
final bool showPlayButton =
widget.showPlayButton && !_dragging && !notifier.hideStuff;

Expand Down Expand Up @@ -424,7 +424,7 @@ class _MaterialControlsState extends State<MaterialControls>
text: '${formatDuration(position)} ',
children: <InlineSpan>[
TextSpan(
text: '/ ${formatDuration(duration)}',
text: '/ ${formatDuration(duration!)}',
style: TextStyle(
fontSize: 14.0,
color: Colors.white.withOpacity(.75),
Expand Down Expand Up @@ -515,7 +515,7 @@ class _MaterialControlsState extends State<MaterialControls>
}

void _playPause() {
final isFinished = _latestValue.position >= _latestValue.duration;
final isFinished = _latestValue.position >= _latestValue.duration!;

setState(() {
if (controller.value.isPlaying) {
Expand All @@ -525,7 +525,7 @@ class _MaterialControlsState extends State<MaterialControls>
} else {
_cancelAndRestartTimer();

if (!controller.value.isInitialized) {
if (!controller.value.initialized) {
controller.initialize().then((_) {
controller.play();
});
Expand Down
10 changes: 5 additions & 5 deletions lib/src/material/material_desktop_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import 'package:chewie/src/material/widgets/playback_speed_dialog.dart';
import 'package:chewie/src/models/option_item.dart';
import 'package:chewie/src/models/subtitle_model.dart';
import 'package:chewie/src/notifiers/index.dart';
import 'package:ext_video_player/ext_video_player.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:video_player/video_player.dart';

class MaterialDesktopControls extends StatefulWidget {
const MaterialDesktopControls({
Expand Down Expand Up @@ -325,7 +325,7 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
}

Widget _buildHitArea() {
final bool isFinished = _latestValue.position >= _latestValue.duration;
final bool isFinished = _latestValue.position >= _latestValue.duration!;
final bool showPlayButton =
widget.showPlayButton && !_dragging && !notifier.hideStuff;

Expand Down Expand Up @@ -437,7 +437,7 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
final duration = _latestValue.duration;

return Text(
'${formatDuration(position)} / ${formatDuration(duration)}',
'${formatDuration(position)} / ${formatDuration(duration!)}',
style: const TextStyle(
fontSize: 14.0,
color: Colors.white,
Expand Down Expand Up @@ -495,7 +495,7 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
}

void _playPause() {
final isFinished = _latestValue.position >= _latestValue.duration;
final isFinished = _latestValue.position >= _latestValue.duration!;

setState(() {
if (controller.value.isPlaying) {
Expand All @@ -505,7 +505,7 @@ class _MaterialDesktopControlsState extends State<MaterialDesktopControls>
} else {
_cancelAndRestartTimer();

if (!controller.value.isInitialized) {
if (!controller.value.initialized) {
controller.initialize().then((_) {
controller.play();
});
Expand Down
2 changes: 1 addition & 1 deletion lib/src/material/material_progress_bar.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:chewie/src/chewie_progress_colors.dart';
import 'package:chewie/src/progress_bar.dart';
import 'package:ext_video_player/ext_video_player.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';

class MaterialVideoProgressBar extends StatelessWidget {
MaterialVideoProgressBar(
Expand Down
2 changes: 1 addition & 1 deletion lib/src/player_with_controls.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:chewie/src/chewie_player.dart';
import 'package:chewie/src/helpers/adaptive_controls.dart';
import 'package:chewie/src/notifiers/index.dart';
import 'package:ext_video_player/ext_video_player.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:video_player/video_player.dart';

class PlayerWithControls extends StatelessWidget {
const PlayerWithControls({Key? key}) : super(key: key);
Expand Down
Loading