v1.4.2+63
All checks were successful
Flutter Schmutter / build (push) Successful in 3m51s

This commit is contained in:
2025-06-21 16:28:57 +02:00
parent 73a44bb269
commit 7a88c23e57
10 changed files with 285 additions and 156 deletions

View File

@ -32,6 +32,8 @@ class _VideoWidgetState extends State<VideoWidget> {
final MediaController controller = Get.find<MediaController>();
late CachedVideoPlayerPlusController _controller;
late Worker _muteWorker;
late Worker _timerResetWorker;
late Worker _hideControlsWorker;
bool _showControls = false;
Timer? _hideControlsTimer;
@ -44,11 +46,26 @@ class _VideoWidgetState extends State<VideoWidget> {
_controller.setVolume(muted ? 0.0 : 1.0);
}
});
_timerResetWorker = ever(controller.videoControlsTimerNotifier, (_) {
if (widget.isActive && mounted) {
if (!_showControls) {
setState(() => _showControls = true);
}
_startHideControlsTimer();
}
});
_hideControlsWorker = ever(controller.hideControlsNotifier, (_) {
if (mounted && _showControls) {
setState(() => _showControls = false);
_hideControlsTimer?.cancel();
}
});
}
Future<void> _initController() async {
_controller = CachedVideoPlayerPlusController.networkUrl(
Uri.parse(widget.details.mediaUrl),
videoPlayerOptions: VideoPlayerOptions(mixWithOthers: true),
);
await _controller.initialize();
widget.onInitialized?.call();
@ -78,20 +95,35 @@ class _VideoWidgetState extends State<VideoWidget> {
@override
void dispose() {
_muteWorker.dispose();
_timerResetWorker.dispose();
_hideControlsWorker.dispose();
_controller.dispose();
_hideControlsTimer?.cancel();
super.dispose();
}
void _onTap({bool ctrlButton = false}) {
if (!ctrlButton) {
setState(() => _showControls = !_showControls);
}
if (_showControls) {
_hideControlsTimer?.cancel();
_hideControlsTimer = Timer(const Duration(seconds: 2), () {
void _startHideControlsTimer() {
_hideControlsTimer?.cancel();
_hideControlsTimer = Timer(const Duration(seconds: 3), () {
if (mounted) {
setState(() => _showControls = false);
});
}
});
}
void _onTap({bool ctrlButton = false}) {
if (ctrlButton) {
_startHideControlsTimer();
return;
}
final bool newShowState = !_showControls;
setState(() => _showControls = newShowState);
if (newShowState) {
_startHideControlsTimer();
} else {
_hideControlsTimer?.cancel();
}
}