[GH-ISSUE #146] Current Playing Notifications #81

Open
opened 2026-02-28 14:46:51 +03:00 by kerem · 5 comments
Owner

Originally created by @SethGower on GitHub (Nov 11, 2019).
Original GitHub issue: https://github.com/Rigellute/spotify-tui/issues/146

A feature I really enjoy in the official Spotify Client, which I would like to see in spt is the current playing notification. It includes the song title, artist and album art. I have been debating on which service to implement this in, whether it should go in spt or spotifyd, and figure the best and most efficient way of implementing it would be in spt since all of the track information is already available, and there is already an API key entangled with the service, allowing for the necessary API calls. If it were implemented in spotifyd instead, then a new API key would need to be generated in order to get the current playing art, info, etc. I am making this issue to solely to have this recorded somewhere, but I plan on implementing this in the nearish future. Also wanted to get any input from other contributors if you all had any other ideas/suggestions. Here is an example of what I am talking about (pardon the Christmas music in November).
image

Originally created by @SethGower on GitHub (Nov 11, 2019). Original GitHub issue: https://github.com/Rigellute/spotify-tui/issues/146 A feature I really enjoy in the official Spotify Client, which I would like to see in `spt` is the current playing notification. It includes the song title, artist and album art. I have been debating on which service to implement this in, whether it should go in `spt` or `spotifyd`, and figure the best and most efficient way of implementing it would be in `spt` since all of the track information is already available, and there is already an API key entangled with the service, allowing for the necessary API calls. If it were implemented in `spotifyd` instead, then a new API key would need to be generated in order to get the current playing art, info, etc. I am making this issue to solely to have this recorded somewhere, but I plan on implementing this in the nearish future. Also wanted to get any input from other contributors if you all had any other ideas/suggestions. Here is an example of what I am talking about (pardon the Christmas music in November). ![image](https://user-images.githubusercontent.com/19225089/68553289-d42be380-03ed-11ea-9573-51d271255d8c.png)
Author
Owner

@Rigellute commented on GitHub (Nov 11, 2019):

Interesting idea - are these operating system notifications?

<!-- gh-comment-id:552385516 --> @Rigellute commented on GitHub (Nov 11, 2019): Interesting idea - are these operating system notifications?
Author
Owner

@SethGower commented on GitHub (Nov 11, 2019):

@Rigellute Yes. I was planning on implementing using libnotify, as Spotify client does

<!-- gh-comment-id:552462300 --> @SethGower commented on GitHub (Nov 11, 2019): @Rigellute Yes. I was planning on implementing using `libnotify`, as Spotify client does
Author
Owner

@SethGower commented on GitHub (Nov 12, 2019):

I have finished creating the function to actually send the notification. It looks Almost identical to the notification that spotify serves.
image

Now that I have it working, I could use some help on figuring out where to actually implement it. If you want to see the code, it is here. I need to find a way to only call the function when the song has changed/when the state has changed. Any suggestions?

<!-- gh-comment-id:552909761 --> @SethGower commented on GitHub (Nov 12, 2019): I have finished creating the function to actually send the notification. It looks Almost identical to the notification that spotify serves. ![image](https://user-images.githubusercontent.com/19225089/68677905-e495a880-052a-11ea-83a8-a899b79784e2.png) Now that I have it working, I could use some help on figuring out where to actually implement it. If you want to see the code, it is [here](https://github.com/SethGower/spotify-tui/commit/233715aeebd60ad3f98311a94e6929d19f54d8e9). I need to find a way to only call the function when the song has changed/when the state has changed. Any suggestions?
Author
Owner

@Rigellute commented on GitHub (Nov 13, 2019):

There's currently no elegant way of checking if the song has changed.

Every 5 seconds we poll the spotify API for current playback context. After certain events (like skipping a track) we also attempt to fetch playback context, but there is a race here so the response is not always accurate.

I would put the "has song changed" logic in get_current_playback function here https://github.com/Rigellute/spotify-tui/blob/master/src/app.rs#L332

Check if the local playback context is different from the context we've fetched from the API (use the track id).

This would be something like self.current_playback_context.item.track.id (although you'd need to handle the Options in this chain).

Hope that makes sense?

<!-- gh-comment-id:553304673 --> @Rigellute commented on GitHub (Nov 13, 2019): There's currently no elegant way of checking if the song has changed. Every 5 seconds we poll the spotify API for current playback context. After certain events (like skipping a track) we also attempt to fetch playback context, but there is a race here so the response is not always accurate. I would put the "has song changed" logic in `get_current_playback` function here https://github.com/Rigellute/spotify-tui/blob/master/src/app.rs#L332 Check if the local playback context is different from the context we've fetched from the API (use the track id). This would be something like `self.current_playback_context.item.track.id` (although you'd need to handle the Options in this chain). Hope that makes sense?
Author
Owner

@SethGower commented on GitHub (Nov 13, 2019):

Ok, that was what I was thinking. I figured I would just mention it, in case I missed it, given I am still becoming familiar with rust. Thanks for all of the help!

<!-- gh-comment-id:553460063 --> @SethGower commented on GitHub (Nov 13, 2019): Ok, that was what I was thinking. I figured I would just mention it, in case I missed it, given I am still becoming familiar with rust. Thanks for all of the help!
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#81
No description provided.