1.0.25+25
All checks were successful
Flutter Schmutter / build (push) Successful in 3m16s

- preload adjacent media
This commit is contained in:
2025-06-05 08:41:48 +02:00
parent 05484b342a
commit ae5f395331
4 changed files with 56 additions and 16 deletions

View File

@ -7,7 +7,9 @@ import 'dart:async';
class VideoWidget extends StatefulWidget {
final MediaItem details;
const VideoWidget({super.key, required this.details});
final bool isActive;
const VideoWidget({super.key, required this.details, required this.isActive});
@override
State createState() => _VideoWidgetState();
@ -32,7 +34,9 @@ class _VideoWidgetState extends State<VideoWidget> {
setState(() {});
_controller.addListener(() => setState(() {}));
_controller.play();
if (widget.isActive) {
_controller.play();
}
_controller.setLooping(true);
}
@ -43,6 +47,16 @@ class _VideoWidgetState extends State<VideoWidget> {
super.dispose();
}
@override
void didUpdateWidget(VideoWidget oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.isActive) {
_controller.play();
} else {
_controller.pause();
}
}
void _onTap({bool ctrlButton = false}) {
if (!ctrlButton) {
setState(() => _showControls = !_showControls);
@ -81,7 +95,7 @@ class _VideoWidgetState extends State<VideoWidget> {
errorWidget: (context, url, error) => Image.asset(
'assets/images/music.webp',
fit: BoxFit.contain,
width: double.infinity
width: double.infinity,
),
)
: _controller.value.isInitialized