mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
[mob][photos] Do not hide controls when seeking + Hide controls after seeking + do not surface controls when video starts over when playing in loop:
This commit is contained in:
parent
4cb0a5306a
commit
f7345102a2
@ -9,7 +9,8 @@ import "package:photos/utils/debouncer.dart";
|
||||
class SeekBar extends StatefulWidget {
|
||||
final NativeVideoPlayerController controller;
|
||||
final int? duration;
|
||||
const SeekBar(this.controller, this.duration, {super.key});
|
||||
final ValueNotifier<bool> isSeeking;
|
||||
const SeekBar(this.controller, this.duration, this.isSeeking, {super.key});
|
||||
|
||||
@override
|
||||
State<SeekBar> createState() => _SeekBarState();
|
||||
@ -73,6 +74,9 @@ class _SeekBarState extends State<SeekBar> with SingleTickerProviderStateMixin {
|
||||
min: 0.0,
|
||||
max: 1.0,
|
||||
value: _animationController.value,
|
||||
onChangeStart: (value) {
|
||||
widget.isSeeking.value = true;
|
||||
},
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_animationController.value = value;
|
||||
@ -85,6 +89,7 @@ class _SeekBarState extends State<SeekBar> with SingleTickerProviderStateMixin {
|
||||
_animationController.value = value;
|
||||
});
|
||||
_seekTo(value);
|
||||
widget.isSeeking.value = false;
|
||||
},
|
||||
allowedInteraction: SliderInteraction.tapAndSlide,
|
||||
),
|
||||
|
@ -62,6 +62,7 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
|
||||
bool _shouldClearCache = false;
|
||||
bool _isCompletelyVisible = false;
|
||||
final _showControls = ValueNotifier(true);
|
||||
final _isSeeking = ValueNotifier(false);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -143,6 +144,8 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
|
||||
.removeListener(_onPlaybackStatusChanged);
|
||||
_isPlaybackReady.dispose();
|
||||
_showControls.dispose();
|
||||
_isSeeking.removeListener(_isSeekingListener);
|
||||
_isSeeking.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@ -313,6 +316,7 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
|
||||
_durationToSeconds(
|
||||
duration,
|
||||
),
|
||||
_isSeeking,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
@ -391,6 +395,7 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
|
||||
controller.onPlaybackEnded.addListener(_onPlaybackEnded);
|
||||
controller.onPlaybackReady.addListener(_onPlaybackReady);
|
||||
controller.onPlaybackStatusChanged.addListener(_onPlaybackStatusChanged);
|
||||
_isSeeking.addListener(_isSeekingListener);
|
||||
|
||||
final videoSource = await VideoSource.init(
|
||||
path: _filePath!,
|
||||
@ -402,7 +407,23 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
|
||||
}
|
||||
}
|
||||
|
||||
void _isSeekingListener() {
|
||||
if (!_isSeeking.value &&
|
||||
_controller?.playbackInfo?.status == PlaybackStatus.playing) {
|
||||
Future.delayed(const Duration(milliseconds: 1500), () {
|
||||
if (mounted) {
|
||||
_showControls.value = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
///Need to not execute this if the status change is coming from a video getting
|
||||
///played in loop.
|
||||
void _onPlaybackStatusChanged() {
|
||||
if (_isSeeking.value || _controller?.playbackInfo?.positionFraction == 1) {
|
||||
return;
|
||||
}
|
||||
if (_controller!.playbackInfo?.status == PlaybackStatus.playing) {
|
||||
if (widget.playbackCallback != null && mounted) {
|
||||
Future.delayed(const Duration(milliseconds: 1500), () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user