From dc87a4369ea887b4bc3cf44a0f2fe2e72e0ba492 Mon Sep 17 00:00:00 2001 From: lukas-heiligenbrunner Date: Wed, 31 Aug 2022 16:30:34 +0200 Subject: [PATCH] use betterplayer instead of chewie --- lib/video_screen/videoscreen_mobile.dart | 36 ++++---- pubspec.lock | 103 +++++++++-------------- pubspec.yaml | 3 +- 3 files changed, 57 insertions(+), 85 deletions(-) diff --git a/lib/video_screen/videoscreen_mobile.dart b/lib/video_screen/videoscreen_mobile.dart index 61e5e41..495fa55 100644 --- a/lib/video_screen/videoscreen_mobile.dart +++ b/lib/video_screen/videoscreen_mobile.dart @@ -1,6 +1,5 @@ -import 'package:chewie/chewie.dart'; +import 'package:better_player/better_player.dart'; import 'package:flutter/material.dart'; -import 'package:video_player/video_player.dart'; class VideoScreenMobile extends StatefulWidget { const VideoScreenMobile({Key? key, required this.url}) : super(key: key); @@ -11,27 +10,28 @@ class VideoScreenMobile extends StatefulWidget { } class _VideoScreenMobileState extends State { - ChewieController? _chewieController; + BetterPlayerController? _betterPlayerController; @override Widget build(BuildContext context) { - if (_chewieController == null) { + if (_betterPlayerController == null) { return Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: const [CircularProgressIndicator(), Text("loading...")], ); + } else { + return BetterPlayer( + controller: _betterPlayerController!, + ); } - return Chewie( - controller: _chewieController!, - ); } @override void dispose() { super.dispose(); - _chewieController?.videoPlayerController.dispose(); - _chewieController?.dispose(); + _betterPlayerController?.videoPlayerController?.dispose(); + _betterPlayerController?.dispose(); } @override @@ -41,18 +41,12 @@ class _VideoScreenMobileState extends State { } void _init() async { - final VideoPlayerController _controller = - VideoPlayerController.network(widget.url); - await _controller.initialize(); - - _chewieController = ChewieController( - videoPlayerController: _controller, - autoPlay: true, - looping: true, - allowFullScreen: true, - allowMuting: true, - allowPlaybackSpeedChanging: true, - zoomAndPan: true); + BetterPlayerDataSource betterPlayerDataSource = + BetterPlayerDataSource(BetterPlayerDataSourceType.network, widget.url); + _betterPlayerController = BetterPlayerController( + BetterPlayerConfiguration( + autoPlay: true, looping: true, allowedScreenSleep: false), + betterPlayerDataSource: betterPlayerDataSource); setState(() {}); } diff --git a/pubspec.lock b/pubspec.lock index 9d1459f..8be756e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -15,6 +15,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.10.0" + better_player: + dependency: "direct main" + description: + name: better_player + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.83" boolean_selector: dependency: transitive description: @@ -36,13 +43,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.1" - chewie: - dependency: "direct main" - description: - name: chewie - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.2" clock: dependency: transitive description: @@ -70,7 +70,7 @@ packages: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.0.5" dart_vlc: dependency: "direct main" description: @@ -219,6 +219,20 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_widget_from_html_core: + dependency: transitive + description: + name: flutter_widget_from_html_core + url: "https://pub.dartlang.org" + source: hosted + version: "0.8.5+3" + fwfh_text_style: + dependency: transitive + description: + name: fwfh_text_style + url: "https://pub.dartlang.org" + source: hosted + version: "2.22.08" html: dependency: transitive description: @@ -282,13 +296,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.7.0" - nested: - dependency: transitive - description: - name: nested - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.0" path: dependency: "direct main" description: @@ -302,7 +309,7 @@ packages: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "2.0.9" + version: "2.0.11" path_provider_android: dependency: transitive description: @@ -345,6 +352,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.5" + petitparser: + dependency: transitive + description: + name: petitparser + url: "https://pub.dartlang.org" + source: hosted + version: "5.0.0" platform: dependency: transitive description: @@ -366,13 +380,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.2.4" - provider: - dependency: transitive - description: - name: provider - url: "https://pub.dartlang.org" - source: hosted - version: "6.0.2" sky_engine: dependency: transitive description: flutter @@ -469,48 +476,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.2" - very_good_analysis: + visibility_detector: dependency: transitive description: - name: very_good_analysis + name: visibility_detector url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" - video_player: - dependency: "direct main" - description: - name: video_player - url: "https://pub.dartlang.org" - source: hosted - version: "2.3.0" - video_player_android: - dependency: transitive - description: - name: video_player_android - url: "https://pub.dartlang.org" - source: hosted - version: "2.3.2" - video_player_avfoundation: - dependency: transitive - description: - name: video_player_avfoundation - url: "https://pub.dartlang.org" - source: hosted - version: "2.3.1" - video_player_platform_interface: - dependency: transitive - description: - name: video_player_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "5.1.1" - video_player_web: - dependency: transitive - description: - name: video_player_web - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.7" + version: "0.3.3" wakelock: dependency: transitive description: @@ -560,6 +532,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.2.0+1" + xml: + dependency: transitive + description: + name: xml + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.0" sdks: - dart: ">=2.17.0-206.0.dev <3.0.0" + dart: ">=2.17.0 <3.0.0" flutter: ">=3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 7f5f6e2..d6c2317 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -40,11 +40,10 @@ dependencies: flutter_staggered_grid_view: ^0.6.1 dart_vlc: ^0.1.9 device_info_plus: ^3.2.3 - video_player: ^2.3.0 - chewie: ^1.3.2 sqflite: ^2.0.3+1 path: ^1.8.1 sqflite_common_ffi: ^2.1.1+1 + better_player: ^0.0.83 dev_dependencies: flutter_test: