removes unused function callbacks and moves wakelock
This commit is contained in:
@@ -7,7 +7,6 @@ import 'package:immich_mobile/shared/models/asset.dart';
|
|||||||
import 'package:immich_mobile/shared/models/store.dart';
|
import 'package:immich_mobile/shared/models/store.dart';
|
||||||
import 'package:video_player/video_player.dart';
|
import 'package:video_player/video_player.dart';
|
||||||
import 'package:immich_mobile/shared/models/store.dart' as store;
|
import 'package:immich_mobile/shared/models/store.dart' as store;
|
||||||
import 'package:wakelock_plus/wakelock_plus.dart';
|
|
||||||
|
|
||||||
/// Provides the initialized video player controller
|
/// Provides the initialized video player controller
|
||||||
/// If the asset is local, use the local file
|
/// 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();
|
await videoPlayerController!.initialize();
|
||||||
|
|
||||||
chewieController = ChewieController(
|
chewieController = ChewieController(
|
||||||
|
|||||||
@@ -446,11 +446,6 @@ class GalleryViewerPage extends HookConsumerWidget {
|
|||||||
width: context.width,
|
width: context.width,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
),
|
),
|
||||||
onVideoEnded: () {
|
|
||||||
if (isPlayingMotionVideo.value) {
|
|
||||||
isPlayingMotionVideo.value = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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/modules/asset_viewer/ui/custom_video_player_controls.dart';
|
||||||
import 'package:immich_mobile/shared/models/asset.dart';
|
import 'package:immich_mobile/shared/models/asset.dart';
|
||||||
import 'package:immich_mobile/shared/ui/delayed_loading_indicator.dart';
|
import 'package:immich_mobile/shared/ui/delayed_loading_indicator.dart';
|
||||||
|
import 'package:wakelock_plus/wakelock_plus.dart';
|
||||||
|
|
||||||
@RoutePage()
|
@RoutePage()
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
@@ -17,9 +18,6 @@ class VideoViewerPage extends HookConsumerWidget {
|
|||||||
final Asset asset;
|
final Asset asset;
|
||||||
final bool isMotionVideo;
|
final bool isMotionVideo;
|
||||||
final Widget? placeholder;
|
final Widget? placeholder;
|
||||||
final VoidCallback? onVideoEnded;
|
|
||||||
final VoidCallback? onPlaying;
|
|
||||||
final VoidCallback? onPaused;
|
|
||||||
final Duration hideControlsTimer;
|
final Duration hideControlsTimer;
|
||||||
final bool showControls;
|
final bool showControls;
|
||||||
final bool showDownloadingIndicator;
|
final bool showDownloadingIndicator;
|
||||||
@@ -28,9 +26,6 @@ class VideoViewerPage extends HookConsumerWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
required this.asset,
|
required this.asset,
|
||||||
this.isMotionVideo = false,
|
this.isMotionVideo = false,
|
||||||
this.onVideoEnded,
|
|
||||||
this.onPlaying,
|
|
||||||
this.onPaused,
|
|
||||||
this.placeholder,
|
this.placeholder,
|
||||||
this.showControls = true,
|
this.showControls = true,
|
||||||
this.hideControlsTimer = const Duration(seconds: 5),
|
this.hideControlsTimer = const Duration(seconds: 5),
|
||||||
@@ -50,9 +45,6 @@ class VideoViewerPage extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
showControls: showControls && !isMotionVideo,
|
showControls: showControls && !isMotionVideo,
|
||||||
hideControlsTimer: hideControlsTimer,
|
hideControlsTimer: hideControlsTimer,
|
||||||
onPlaying: onPlaying,
|
|
||||||
onPaused: onPaused,
|
|
||||||
onVideoEnded: onVideoEnded,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// The last volume of the video used when mute is toggled
|
// 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]
|
// position and duration of the video from the Chewie [controller]
|
||||||
// Also sets the error if there is an error in the playback
|
// Also sets the error if there is an error in the playback
|
||||||
void updateVideoPlayback() {
|
void updateVideoPlayback() {
|
||||||
ref.read(videoPlaybackValueProvider.notifier).value =
|
final videoPlayback = VideoPlaybackValue.fromController(
|
||||||
VideoPlaybackValue.fromController(
|
|
||||||
controller?.videoPlayerController,
|
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
|
// Adds and removes the listener to the video player
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ class MemoryCard extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
hideControlsTimer: const Duration(seconds: 2),
|
hideControlsTimer: const Duration(seconds: 2),
|
||||||
onVideoEnded: onVideoEnded,
|
|
||||||
showControls: false,
|
showControls: false,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -350,9 +350,6 @@ abstract class _$AppRouter extends RootStackRouter {
|
|||||||
key: args.key,
|
key: args.key,
|
||||||
asset: args.asset,
|
asset: args.asset,
|
||||||
isMotionVideo: args.isMotionVideo,
|
isMotionVideo: args.isMotionVideo,
|
||||||
onVideoEnded: args.onVideoEnded,
|
|
||||||
onPlaying: args.onPlaying,
|
|
||||||
onPaused: args.onPaused,
|
|
||||||
placeholder: args.placeholder,
|
placeholder: args.placeholder,
|
||||||
showControls: args.showControls,
|
showControls: args.showControls,
|
||||||
hideControlsTimer: args.hideControlsTimer,
|
hideControlsTimer: args.hideControlsTimer,
|
||||||
|
|||||||
Reference in New Issue
Block a user