mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
fix: rewind breaks track progress bar (#695)
This commit is contained in:
parent
d3e1cef8a2
commit
e3217436c9
@ -40,14 +40,14 @@ import 'package:spotube/services/audio_player/audio_player.dart';
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var lastPosition = position.value;
|
||||||
|
|
||||||
// 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
|
// Reduces CPU usage
|
||||||
var lastPosition = position.value;
|
|
||||||
|
|
||||||
final positionSubscription = audioPlayer.positionStream.listen((event) {
|
final positionSubscription = audioPlayer.positionStream.listen((event) {
|
||||||
if (event.inMilliseconds > 1000 &&
|
final diff = event.inMilliseconds - lastPosition.inMilliseconds;
|
||||||
event.inMilliseconds - lastPosition.inMilliseconds < 1000) return;
|
if (event.inMilliseconds > 1000 && diff < 1000 && diff > 0) return;
|
||||||
|
|
||||||
lastPosition = event;
|
lastPosition = event;
|
||||||
position.value = event;
|
position.value = event;
|
||||||
|
Loading…
Reference in New Issue
Block a user