2024-03-06 04:42:22 +01:00
|
|
|
import 'package:chewie/chewie.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2024-05-10 18:40:41 +02:00
|
|
|
import 'package:immich_mobile/utils/hooks/chewiew_controller_hook.dart';
|
2024-05-07 06:04:21 +02:00
|
|
|
import 'package:immich_mobile/widgets/asset_viewer/custom_video_player_controls.dart';
|
2024-03-06 04:42:22 +01:00
|
|
|
import 'package:video_player/video_player.dart';
|
|
|
|
|
|
|
|
class VideoPlayerViewer extends HookConsumerWidget {
|
|
|
|
final VideoPlayerController controller;
|
|
|
|
final bool isMotionVideo;
|
|
|
|
final Widget? placeholder;
|
|
|
|
final Duration hideControlsTimer;
|
|
|
|
final bool showControls;
|
|
|
|
final bool showDownloadingIndicator;
|
2024-05-14 21:31:47 +02:00
|
|
|
final bool loopVideo;
|
2024-03-06 04:42:22 +01:00
|
|
|
|
|
|
|
const VideoPlayerViewer({
|
|
|
|
super.key,
|
|
|
|
required this.controller,
|
|
|
|
required this.isMotionVideo,
|
|
|
|
this.placeholder,
|
|
|
|
required this.hideControlsTimer,
|
|
|
|
required this.showControls,
|
|
|
|
required this.showDownloadingIndicator,
|
2024-05-14 21:31:47 +02:00
|
|
|
required this.loopVideo,
|
2024-03-06 04:42:22 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
final chewie = useChewieController(
|
|
|
|
controller: controller,
|
|
|
|
controlsSafeAreaMinimum: const EdgeInsets.only(
|
|
|
|
bottom: 100,
|
|
|
|
),
|
|
|
|
placeholder: SizedBox.expand(child: placeholder),
|
|
|
|
customControls: CustomVideoPlayerControls(
|
|
|
|
hideTimerDuration: hideControlsTimer,
|
|
|
|
),
|
|
|
|
showControls: showControls && !isMotionVideo,
|
|
|
|
hideControlsTimer: hideControlsTimer,
|
2024-05-14 21:31:47 +02:00
|
|
|
loopVideo: loopVideo,
|
2024-03-06 04:42:22 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
return Chewie(
|
|
|
|
controller: chewie,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|