Fixed wakelock simple video player

This commit is contained in:
PartyDonut 2024-12-20 15:34:57 +01:00
parent e545647e0c
commit 0cf1b5aef8

View file

@ -100,11 +100,6 @@ class _SimpleVideoPlayerState extends ConsumerState<SimpleVideoPlayer> with Wind
position = event.position; position = event.position;
duration = event.duration; duration = event.duration;
}); });
if (playing) {
WakelockPlus.enable();
} else {
WakelockPlus.disable();
}
})); }));
await player.open(videoUrl, !ref.watch(photoViewSettingsProvider).autoPlay); await player.open(videoUrl, !ref.watch(photoViewSettingsProvider).autoPlay);
await player.setVolume(ref.watch(photoViewSettingsProvider.select((value) => value.mute)) ? 0 : 100); await player.setVolume(ref.watch(photoViewSettingsProvider.select((value) => value.mute)) ? 0 : 100);
@ -220,8 +215,13 @@ class _SimpleVideoPlayerState extends ConsumerState<SimpleVideoPlayer> with Wind
const SizedBox(width: 16), const SizedBox(width: 16),
IconButton( IconButton(
color: Theme.of(context).colorScheme.onSurface, color: Theme.of(context).colorScheme.onSurface,
onPressed: () { onPressed: () async {
player.playOrPause(); await player.playOrPause();
if (player.lastState.playing) {
WakelockPlus.enable();
} else {
WakelockPlus.disable();
}
}, },
icon: Icon( icon: Icon(
player.lastState.playing ? IconsaxBold.pause_circle : IconsaxBold.play_circle, player.lastState.playing ? IconsaxBold.pause_circle : IconsaxBold.play_circle,