mirror of
				https://github.com/immich-app/immich.git
				synced 2025-10-31 10:49:11 -04:00 
			
		
		
		
	* Fixes double video auto initialize issue and placeholder for video controller * WIP unravel stack index * Refactors video player controller format fixing video format Working format * Fixes hide on pause * Got hiding when tapped working * Hides controls when video starts and fixes placeholder for memory card Remove prints * Fixes show controls with microtask * fix LivePhotos not playing * removes unused function callbacks and moves wakelock * Update motion video * Fixing motion photo playing * Renames to isPlayingVideo * Fixes playing video on change * pause on dispose * fixing issues with sync between controls * Adds gallery app bar * Switches to memoized * Fixes pause * Revert "Switches to memoized" This reverts commit 234e6741dea05aa0b967dde746f1d625f15bed94. * uses stateful widget * Fixes double video play by using provider and new chewie video player wip format Fixes motion photos format --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
		
			
				
	
	
		
			49 lines
		
	
	
		
			994 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			994 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'package:async/async.dart';
 | |
| import 'package:flutter/material.dart';
 | |
| import 'package:flutter_hooks/flutter_hooks.dart';
 | |
| 
 | |
| RestartableTimer useTimer(
 | |
|   Duration duration,
 | |
|   void Function() callback,
 | |
| ) {
 | |
|   return use(
 | |
|     _TimerHook(
 | |
|       duration: duration,
 | |
|       callback: callback,
 | |
|     ),
 | |
|   );
 | |
| }
 | |
| 
 | |
| class _TimerHook extends Hook<RestartableTimer> {
 | |
|   final Duration duration;
 | |
|   final void Function() callback;
 | |
| 
 | |
|   const _TimerHook({
 | |
|     required this.duration,
 | |
|     required this.callback,
 | |
|   });
 | |
|   @override
 | |
|   HookState<RestartableTimer, Hook<RestartableTimer>> createState() =>
 | |
|       _TimerHookState();
 | |
| }
 | |
| 
 | |
| class _TimerHookState extends HookState<RestartableTimer, _TimerHook> {
 | |
|   late RestartableTimer timer;
 | |
|   @override
 | |
|   void initHook() {
 | |
|     super.initHook();
 | |
|     timer = RestartableTimer(hook.duration, hook.callback);
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   RestartableTimer build(BuildContext context) {
 | |
|     return timer;
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   void dispose() {
 | |
|     timer.cancel();
 | |
|     super.dispose();
 | |
|   }
 | |
| }
 |