From 1f3cbad7bc3e021f5b3d896ea8c0b381c1ce00de Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Fri, 30 Dec 2022 00:18:22 +0800 Subject: [PATCH] Don't loop video during slieshow --- app/lib/widget/slideshow_viewer.dart | 1 + app/lib/widget/video_viewer.dart | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/lib/widget/slideshow_viewer.dart b/app/lib/widget/slideshow_viewer.dart index 4d70cca7..5deb221b 100644 --- a/app/lib/widget/slideshow_viewer.dart +++ b/app/lib/widget/slideshow_viewer.dart @@ -226,6 +226,7 @@ class _SlideshowViewerState extends State Future.delayed(const Duration(seconds: 2), _onSlideshowTick); }, isControlVisible: false, + canLoop: false, ); } diff --git a/app/lib/widget/video_viewer.dart b/app/lib/widget/video_viewer.dart index e8948e20..00d5daba 100644 --- a/app/lib/widget/video_viewer.dart +++ b/app/lib/widget/video_viewer.dart @@ -34,6 +34,7 @@ class VideoViewer extends StatefulWidget { this.onPause, this.isControlVisible = false, this.canPlay = true, + this.canLoop = true, }) : super(key: key); @override @@ -48,6 +49,9 @@ class VideoViewer extends StatefulWidget { final VoidCallback? onPause; final bool isControlVisible; final bool canPlay; + + /// If false, disable the loop control and always stop after playing once + final bool canLoop; } @npLog @@ -112,7 +116,9 @@ class _VideoViewerState extends State await _controller.initialize(); final c = KiwiContainer().resolve(); unawaited(_controller.setVolume(c.pref.isVideoPlayerMuteOr() ? 0 : 1)); - unawaited(_controller.setLooping(c.pref.isVideoPlayerLoopOr())); + if (widget.canLoop) { + unawaited(_controller.setLooping(c.pref.isVideoPlayerLoopOr())); + } widget.onLoaded?.call(); WidgetsBinding.instance.addPostFrameCallback((_) { if (_key.currentContext != null) { @@ -220,7 +226,7 @@ class _VideoViewerState extends State ), ), const SizedBox(width: 4), - _LoopToggle(controller: _controller), + if (widget.canLoop) _LoopToggle(controller: _controller), _MuteToggle(controller: _controller), ], ),