use betterplayer instead of chewie

This commit is contained in:
lukas-heiligenbrunner 2022-08-31 16:30:34 +02:00
parent 395b501925
commit dc87a4369e
3 changed files with 57 additions and 85 deletions

View File

@ -1,6 +1,5 @@
import 'package:chewie/chewie.dart'; import 'package:better_player/better_player.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
class VideoScreenMobile extends StatefulWidget { class VideoScreenMobile extends StatefulWidget {
const VideoScreenMobile({Key? key, required this.url}) : super(key: key); const VideoScreenMobile({Key? key, required this.url}) : super(key: key);
@ -11,27 +10,28 @@ class VideoScreenMobile extends StatefulWidget {
} }
class _VideoScreenMobileState extends State<VideoScreenMobile> { class _VideoScreenMobileState extends State<VideoScreenMobile> {
ChewieController? _chewieController; BetterPlayerController? _betterPlayerController;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (_chewieController == null) { if (_betterPlayerController == null) {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: const [CircularProgressIndicator(), Text("loading...")], children: const [CircularProgressIndicator(), Text("loading...")],
); );
} else {
return BetterPlayer(
controller: _betterPlayerController!,
);
} }
return Chewie(
controller: _chewieController!,
);
} }
@override @override
void dispose() { void dispose() {
super.dispose(); super.dispose();
_chewieController?.videoPlayerController.dispose(); _betterPlayerController?.videoPlayerController?.dispose();
_chewieController?.dispose(); _betterPlayerController?.dispose();
} }
@override @override
@ -41,18 +41,12 @@ class _VideoScreenMobileState extends State<VideoScreenMobile> {
} }
void _init() async { void _init() async {
final VideoPlayerController _controller = BetterPlayerDataSource betterPlayerDataSource =
VideoPlayerController.network(widget.url); BetterPlayerDataSource(BetterPlayerDataSourceType.network, widget.url);
await _controller.initialize(); _betterPlayerController = BetterPlayerController(
BetterPlayerConfiguration(
_chewieController = ChewieController( autoPlay: true, looping: true, allowedScreenSleep: false),
videoPlayerController: _controller, betterPlayerDataSource: betterPlayerDataSource);
autoPlay: true,
looping: true,
allowFullScreen: true,
allowMuting: true,
allowPlaybackSpeedChanging: true,
zoomAndPan: true);
setState(() {}); setState(() {});
} }

View File

@ -15,6 +15,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.10.0" 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: boolean_selector:
dependency: transitive dependency: transitive
description: description:
@ -36,13 +43,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.1" version: "1.3.1"
chewie:
dependency: "direct main"
description:
name: chewie
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.2"
clock: clock:
dependency: transitive dependency: transitive
description: description:
@ -70,7 +70,7 @@ packages:
name: cupertino_icons name: cupertino_icons
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.4" version: "1.0.5"
dart_vlc: dart_vlc:
dependency: "direct main" dependency: "direct main"
description: description:
@ -219,6 +219,20 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" 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: html:
dependency: transitive dependency: transitive
description: description:
@ -282,13 +296,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.7.0" version: "1.7.0"
nested:
dependency: transitive
description:
name: nested
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
path: path:
dependency: "direct main" dependency: "direct main"
description: description:
@ -302,7 +309,7 @@ packages:
name: path_provider name: path_provider
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.9" version: "2.0.11"
path_provider_android: path_provider_android:
dependency: transitive dependency: transitive
description: description:
@ -345,6 +352,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.5" version: "2.0.5"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "5.0.0"
platform: platform:
dependency: transitive dependency: transitive
description: description:
@ -366,13 +380,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.2.4" version: "4.2.4"
provider:
dependency: transitive
description:
name: provider
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.2"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -469,48 +476,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.2" version: "2.1.2"
very_good_analysis: visibility_detector:
dependency: transitive dependency: transitive
description: description:
name: very_good_analysis name: visibility_detector
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.4.0" version: "0.3.3"
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"
wakelock: wakelock:
dependency: transitive dependency: transitive
description: description:
@ -560,6 +532,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.0+1" version: "0.2.0+1"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.0"
sdks: sdks:
dart: ">=2.17.0-206.0.dev <3.0.0" dart: ">=2.17.0 <3.0.0"
flutter: ">=3.0.0" flutter: ">=3.0.0"

View File

@ -40,11 +40,10 @@ dependencies:
flutter_staggered_grid_view: ^0.6.1 flutter_staggered_grid_view: ^0.6.1
dart_vlc: ^0.1.9 dart_vlc: ^0.1.9
device_info_plus: ^3.2.3 device_info_plus: ^3.2.3
video_player: ^2.3.0
chewie: ^1.3.2
sqflite: ^2.0.3+1 sqflite: ^2.0.3+1
path: ^1.8.1 path: ^1.8.1
sqflite_common_ffi: ^2.1.1+1 sqflite_common_ffi: ^2.1.1+1
better_player: ^0.0.83
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: