mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
fix: no progress update when track changed
This commit is contained in:
parent
8be67d02c4
commit
6ae896441a
@ -9,7 +9,7 @@ import 'package:spotube/services/audio_player/audio_player.dart';
|
|||||||
Duration duration,
|
Duration duration,
|
||||||
double bufferProgress
|
double bufferProgress
|
||||||
}) useProgress(WidgetRef ref) {
|
}) useProgress(WidgetRef ref) {
|
||||||
ref.watch(ProxyPlaylistNotifier.provider);
|
final playlist = ref.watch(ProxyPlaylistNotifier.provider);
|
||||||
|
|
||||||
final bufferProgress =
|
final bufferProgress =
|
||||||
useStream(audioPlayer.bufferedPositionStream).data?.inSeconds ?? 0;
|
useStream(audioPlayer.bufferedPositionStream).data?.inSeconds ?? 0;
|
||||||
@ -30,9 +30,11 @@ import 'package:spotube/services/audio_player/audio_player.dart';
|
|||||||
useEffect(() {
|
useEffect(() {
|
||||||
// audioPlayer.positionStream is fired every 200ms and only 1s delay is
|
// audioPlayer.positionStream is fired every 200ms and only 1s delay is
|
||||||
// enough. Thus only update the position if the difference is more than 1s
|
// enough. Thus only update the position if the difference is more than 1s
|
||||||
|
// Reduces CPU usage
|
||||||
var lastPosition = position.value;
|
var lastPosition = position.value;
|
||||||
return audioPlayer.positionStream.listen((event) {
|
return audioPlayer.positionStream.listen((event) {
|
||||||
if (event.inMilliseconds - lastPosition.inMilliseconds < 1000) return;
|
if (event.inMilliseconds > 1000 &&
|
||||||
|
event.inMilliseconds - lastPosition.inMilliseconds < 1000) return;
|
||||||
lastPosition = event;
|
lastPosition = event;
|
||||||
position.value = event;
|
position.value = event;
|
||||||
}).cancel;
|
}).cancel;
|
||||||
|
Loading…
Reference in New Issue
Block a user