[GH-ISSUE #894] Commandline '-p' works differently than 'p' key in UI #383

Open
opened 2026-02-28 14:48:49 +03:00 by kerem · 1 comment
Owner

Originally created by @PoKnow on GitHub (Oct 1, 2021).
Original GitHub issue: https://github.com/Rigellute/spotify-tui/issues/894

"spt playback -p" does not go back to back to the beginning of the song. Instead it tires to go back to the previous song (acting like "-pp")

UI 'p' works as expected.

Originally created by @PoKnow on GitHub (Oct 1, 2021). Original GitHub issue: https://github.com/Rigellute/spotify-tui/issues/894 "spt playback -p" does not go back to back to the beginning of the song. Instead it tires to go back to the previous song (acting like "-pp") UI 'p' works as expected.
Author
Owner

@aromeronavia commented on GitHub (Nov 29, 2021):

This happens because the general TUI uses a different code than the CLI.
The TUI uses this handler

pub fn previous_track(&mut self) {
    if self.song_progress_ms >= 3_000 {
      self.dispatch(IoEvent::Seek(0));
    } else {
      self.dispatch(IoEvent::PreviousTrack);
    }
  }

And the CLI communicates directly with the Spotify Library to straight go to the previous track (notice there's no IF for the three seconds)

  async fn previous_track(&mut self) {
    match self
      .spotify
      .previous_track(self.client_config.device_id.clone())
      .await
    {
      Ok(()) => {
        self.get_current_playback().await;
      }
      Err(e) => {
        self.handle_error(anyhow!(e)).await;
      }
    };
  }

What we would have to do is to fetch first the current song progress in the CLI process, and then do the same validation to check if three seconds have passed or not. That can be achieved by using current_playing method from RSpotify, get the song timestamp and do the same validation. Does that make sense? @Rigellute

<!-- gh-comment-id:981272340 --> @aromeronavia commented on GitHub (Nov 29, 2021): This happens because the general TUI uses a different code than the CLI. The TUI uses this handler ```rust pub fn previous_track(&mut self) { if self.song_progress_ms >= 3_000 { self.dispatch(IoEvent::Seek(0)); } else { self.dispatch(IoEvent::PreviousTrack); } } ``` And the CLI communicates directly with the Spotify Library to straight go to the previous track (notice there's no IF for the three seconds) ```rust async fn previous_track(&mut self) { match self .spotify .previous_track(self.client_config.device_id.clone()) .await { Ok(()) => { self.get_current_playback().await; } Err(e) => { self.handle_error(anyhow!(e)).await; } }; } ``` What we would have to do is to fetch first the current song progress in the CLI process, and then do the same validation to check if three seconds have passed or not. That can be achieved by using `current_playing` method from RSpotify, get the song timestamp and do the same validation. Does that make sense? @Rigellute
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-tui#383
No description provided.