diff --git a/mobile/lib/modules/asset_viewer/hooks/chewiew_controller_hook.dart b/mobile/lib/modules/asset_viewer/hooks/chewiew_controller_hook.dart index f8736c3fa4..ca015e1816 100644 --- a/mobile/lib/modules/asset_viewer/hooks/chewiew_controller_hook.dart +++ b/mobile/lib/modules/asset_viewer/hooks/chewiew_controller_hook.dart @@ -7,7 +7,6 @@ import 'package:immich_mobile/shared/models/asset.dart'; import 'package:immich_mobile/shared/models/store.dart'; import 'package:video_player/video_player.dart'; import 'package:immich_mobile/shared/models/store.dart' as store; -import 'package:wakelock_plus/wakelock_plus.dart'; /// Provides the initialized video player controller /// If the asset is local, use the local file @@ -138,24 +137,6 @@ class _ChewieControllerHookState ); } - videoPlayerController!.addListener(() { - final value = videoPlayerController!.value; - if (value.isPlaying) { - WakelockPlus.enable(); - hook.onPlaying?.call(); - } else if (!value.isPlaying) { - WakelockPlus.disable(); - hook.onPaused?.call(); - } - - if (value.position != const Duration() && - value.position == value.duration) { - WakelockPlus.disable(); - - hook.onVideoEnded?.call(); - } - }); - await videoPlayerController!.initialize(); chewieController = ChewieController( diff --git a/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart b/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart index f7c43682f1..5c1537e29b 100644 --- a/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart +++ b/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart @@ -446,11 +446,6 @@ class GalleryViewerPage extends HookConsumerWidget { width: context.width, alignment: Alignment.center, ), - onVideoEnded: () { - if (isPlayingMotionVideo.value) { - isPlayingMotionVideo.value = false; - } - }, ), ); } diff --git a/mobile/lib/modules/asset_viewer/views/video_viewer_page.dart b/mobile/lib/modules/asset_viewer/views/video_viewer_page.dart index 8363f8a43d..95b78b6931 100644 --- a/mobile/lib/modules/asset_viewer/views/video_viewer_page.dart +++ b/mobile/lib/modules/asset_viewer/views/video_viewer_page.dart @@ -10,6 +10,7 @@ import 'package:immich_mobile/modules/asset_viewer/providers/video_player_value_ import 'package:immich_mobile/modules/asset_viewer/ui/custom_video_player_controls.dart'; import 'package:immich_mobile/shared/models/asset.dart'; import 'package:immich_mobile/shared/ui/delayed_loading_indicator.dart'; +import 'package:wakelock_plus/wakelock_plus.dart'; @RoutePage() // ignore: must_be_immutable @@ -17,9 +18,6 @@ class VideoViewerPage extends HookConsumerWidget { final Asset asset; final bool isMotionVideo; final Widget? placeholder; - final VoidCallback? onVideoEnded; - final VoidCallback? onPlaying; - final VoidCallback? onPaused; final Duration hideControlsTimer; final bool showControls; final bool showDownloadingIndicator; @@ -28,9 +26,6 @@ class VideoViewerPage extends HookConsumerWidget { super.key, required this.asset, this.isMotionVideo = false, - this.onVideoEnded, - this.onPlaying, - this.onPaused, this.placeholder, this.showControls = true, this.hideControlsTimer = const Duration(seconds: 5), @@ -50,9 +45,6 @@ class VideoViewerPage extends HookConsumerWidget { ), showControls: showControls && !isMotionVideo, hideControlsTimer: hideControlsTimer, - onPlaying: onPlaying, - onPaused: onPaused, - onVideoEnded: onVideoEnded, ); // The last volume of the video used when mute is toggled @@ -96,10 +88,18 @@ class VideoViewerPage extends HookConsumerWidget { // position and duration of the video from the Chewie [controller] // Also sets the error if there is an error in the playback void updateVideoPlayback() { - ref.read(videoPlaybackValueProvider.notifier).value = - VideoPlaybackValue.fromController( + final videoPlayback = VideoPlaybackValue.fromController( controller?.videoPlayerController, ); + ref.read(videoPlaybackValueProvider.notifier).value = videoPlayback; + final state = videoPlayback.state; + + // Enable the WakeLock while the video is playing + if (state == VideoPlaybackState.playing) { + WakelockPlus.enable(); + } else { + WakelockPlus.disable(); + } } // Adds and removes the listener to the video player diff --git a/mobile/lib/modules/memories/ui/memory_card.dart b/mobile/lib/modules/memories/ui/memory_card.dart index c77d6411e8..5a316db279 100644 --- a/mobile/lib/modules/memories/ui/memory_card.dart +++ b/mobile/lib/modules/memories/ui/memory_card.dart @@ -79,7 +79,6 @@ class MemoryCard extends StatelessWidget { ), ), hideControlsTimer: const Duration(seconds: 2), - onVideoEnded: onVideoEnded, showControls: false, ), ); diff --git a/mobile/lib/routing/router.gr.dart b/mobile/lib/routing/router.gr.dart index f6968dafe5..6ea949014d 100644 --- a/mobile/lib/routing/router.gr.dart +++ b/mobile/lib/routing/router.gr.dart @@ -350,9 +350,6 @@ abstract class _$AppRouter extends RootStackRouter { key: args.key, asset: args.asset, isMotionVideo: args.isMotionVideo, - onVideoEnded: args.onVideoEnded, - onPlaying: args.onPlaying, - onPaused: args.onPaused, placeholder: args.placeholder, showControls: args.showControls, hideControlsTimer: args.hideControlsTimer,