File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -152,8 +152,6 @@ pub struct QueueUpdateEvent {
152152pub enum PlayerUpdateReason {
153153 /// Track changed
154154 TrackChanged ,
155- /// Position changed
156- PositionChanged ,
157155 /// Play/pause state changed
158156 PlayPauseChanged ,
159157 /// Shuffle mode changed
@@ -162,6 +160,8 @@ pub enum PlayerUpdateReason {
162160 RepeatChanged ,
163161 /// Context changed
164162 ContextChanged ,
163+ /// Seek detected
164+ SeekChanged ,
165165 /// Other state change
166166 Other ,
167167}
@@ -1244,11 +1244,18 @@ impl SpircTask {
12441244 }
12451245
12461246 // Detect seek: position jump (not just natural progress)
1247- let position_diff =
1248- ( state. position_as_of_timestamp - last. position_as_of_timestamp ) . abs ( ) ;
1249- if position_diff > 5000 {
1250- // threshold: 5 seconds
1251- PlayerUpdateReason :: PositionChanged
1247+ let time_diff = state. timestamp . saturating_sub ( last. timestamp ) ;
1248+ let expected_position = if state. is_playing {
1249+ // Account for natural progression if playing
1250+ last. position_as_of_timestamp + time_diff
1251+ } else {
1252+ // If paused, position shouldn't change
1253+ last. position_as_of_timestamp
1254+ } ;
1255+
1256+ let position_delta = ( state. position_as_of_timestamp as i64 - expected_position as i64 ) . abs ( ) ;
1257+ if position_delta > 5000 {
1258+ PlayerUpdateReason :: SeekChanged
12521259 } else {
12531260 // No significant change detected
12541261 PlayerUpdateReason :: Other
You can’t perform that action at this time.
0 commit comments