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: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<VideoScreenMobile> {
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<VideoScreenMobile> {
}
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(() {});
}

View File

@ -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"

View File

@ -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: