Fixes hide on pause
This commit is contained in:
@@ -22,7 +22,11 @@ class CustomVideoPlayerControls extends HookConsumerWidget {
|
|||||||
final hideTimer = useTimer(
|
final hideTimer = useTimer(
|
||||||
hideTimerDuration,
|
hideTimerDuration,
|
||||||
() {
|
() {
|
||||||
ref.read(showControlsProvider.notifier).show = false;
|
final state = ref.read(videoPlaybackValueProvider).state;
|
||||||
|
// Do not hide on paused
|
||||||
|
if (state != VideoPlaybackState.paused) {
|
||||||
|
ref.read(showControlsProvider.notifier).show = false;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -68,7 +72,7 @@ class CustomVideoPlayerControls extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => showControlsAndStartHideTimer(),
|
onTap: showControlsAndStartHideTimer,
|
||||||
child: AbsorbPointer(
|
child: AbsorbPointer(
|
||||||
absorbing: !ref.watch(showControlsProvider),
|
absorbing: !ref.watch(showControlsProvider),
|
||||||
child: Stack(
|
child: Stack(
|
||||||
|
|||||||
@@ -135,39 +135,46 @@ class VideoViewerPage extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final size = MediaQuery.of(context).size;
|
final size = MediaQuery.of(context).size;
|
||||||
return PopScope(
|
return GestureDetector(
|
||||||
onPopInvoked: (pop) {
|
onTap: () {
|
||||||
ref.read(videoPlaybackValueProvider.notifier).value =
|
if (ref.read(showControlsProvider)) {
|
||||||
VideoPlaybackValue.uninitialized();
|
ref.read(showControlsProvider.notifier).show = false;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: AnimatedSwitcher(
|
child: PopScope(
|
||||||
duration: const Duration(milliseconds: 400),
|
onPopInvoked: (pop) {
|
||||||
child: Stack(
|
ref.read(videoPlaybackValueProvider.notifier).value =
|
||||||
children: [
|
VideoPlaybackValue.uninitialized();
|
||||||
Visibility(
|
},
|
||||||
visible: controller == null,
|
child: AnimatedSwitcher(
|
||||||
child: Stack(
|
duration: const Duration(milliseconds: 400),
|
||||||
children: [
|
child: Stack(
|
||||||
if (placeholder != null) placeholder!,
|
children: [
|
||||||
const Positioned.fill(
|
Visibility(
|
||||||
child: Center(
|
visible: controller == null,
|
||||||
child: DelayedLoadingIndicator(
|
child: Stack(
|
||||||
fadeInDuration: Duration(milliseconds: 500),
|
children: [
|
||||||
|
if (placeholder != null) placeholder!,
|
||||||
|
const Positioned.fill(
|
||||||
|
child: Center(
|
||||||
|
child: DelayedLoadingIndicator(
|
||||||
|
fadeInDuration: Duration(milliseconds: 500),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (controller != null)
|
|
||||||
SizedBox(
|
|
||||||
height: size.height,
|
|
||||||
width: size.width,
|
|
||||||
child: Chewie(
|
|
||||||
controller: controller,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
if (controller != null)
|
||||||
|
SizedBox(
|
||||||
|
height: size.height,
|
||||||
|
width: size.width,
|
||||||
|
child: Chewie(
|
||||||
|
controller: controller,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user