mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 16:05:18 +00:00

Dropping support for search format, track match algorithm in favor of server track cache and alternative track source
25 lines
633 B
Dart
25 lines
633 B
Dart
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:spotube/provider/playlist_queue_provider.dart';
|
|
|
|
int useSyncedLyrics(
|
|
WidgetRef ref,
|
|
Map<int, String> lyricsMap,
|
|
Duration delay,
|
|
) {
|
|
final stream = PlaylistQueueNotifier.position;
|
|
|
|
final currentTime = useState(0);
|
|
|
|
useEffect(() {
|
|
final lol = stream.listen((pos) {
|
|
if (lyricsMap.containsKey(pos.inSeconds)) {
|
|
currentTime.value = pos.inSeconds;
|
|
}
|
|
});
|
|
return () => lol.cancel();
|
|
}, [lyricsMap]);
|
|
|
|
return (Duration(seconds: currentTime.value) + delay).inSeconds;
|
|
}
|