[PR #154] [MERGED] Run onstart/onstop when a new song is loaded #814

Closed
opened 2026-02-27 20:00:04 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/librespot-org/librespot/pull/154
Author: @SimonTeixidor
Created: 2/14/2018
Status: Merged
Merged: 2/25/2018
Merged by: @sashahilton00

Base: masterHead: events-on-prev-next


📝 Commits (10+)

  • 77bea07 Run onstart/onstop when a new song is loaded
  • b0ee031 First attempt at a better playback event system.
  • 1b943d0 Move PlayerEvent into player.
  • 0a6825b Add playing_to_end_of_track method to PlayerState.
  • 3e2e6d6 Send Changed event after song change even if we stop playback.
  • ef48afb Simplify match with if let.
  • 081a282 Removed unreachable cases.
  • 2eb4aa6 Use single program on events, and pass events in envars.
  • 93af49a Send player event messages over futures aware channel.
  • 23d3c15 Just spawn event handlers, don't wait for exit code.

📊 Changes

4 files changed (+130 additions, -72 deletions)

View changed files

📝 playback/src/config.rs (+1 -5)
📝 playback/src/player.rs (+72 -61)
📝 src/main.rs (+24 -6)
src/player_event_handler.rs (+33 -0)

📄 Description

This PR introduces two changes:

  • onstop is run when a new song is loaded, if we were already playing
  • onstart is run when a new song is loaded, if we also start playing it

The previous behaviour was that onstop/onstart were only run if the state went from playing => !playing or !playing => playing. The new behaviour is useful for scripts where you want to run a script on every new song. I would argue that there is a brief stop between two songs, so the names still make sense :)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/librespot-org/librespot/pull/154 **Author:** [@SimonTeixidor](https://github.com/SimonTeixidor) **Created:** 2/14/2018 **Status:** ✅ Merged **Merged:** 2/25/2018 **Merged by:** [@sashahilton00](https://github.com/sashahilton00) **Base:** `master` ← **Head:** `events-on-prev-next` --- ### 📝 Commits (10+) - [`77bea07`](https://github.com/librespot-org/librespot/commit/77bea07c4f13f7f3f41ae723e2052cabe61d027f) Run onstart/onstop when a new song is loaded - [`b0ee031`](https://github.com/librespot-org/librespot/commit/b0ee03112fdb54eec2b9e0b91cd8558b48a77cb0) First attempt at a better playback event system. - [`1b943d0`](https://github.com/librespot-org/librespot/commit/1b943d069f34617c5d86db74730869536ddd21e7) Move PlayerEvent into player. - [`0a6825b`](https://github.com/librespot-org/librespot/commit/0a6825ba61e1c321b13f407f8b7da29ba420a32f) Add playing_to_end_of_track method to PlayerState. - [`3e2e6d6`](https://github.com/librespot-org/librespot/commit/3e2e6d63f7c3a6216d49ddb1d57c7f89c09a6981) Send Changed event after song change even if we stop playback. - [`ef48afb`](https://github.com/librespot-org/librespot/commit/ef48afbf418759b04af5d6752501a590511e80a0) Simplify match with if let. - [`081a282`](https://github.com/librespot-org/librespot/commit/081a282e12ce755a0a8e301a95568b6ac6400450) Removed unreachable cases. - [`2eb4aa6`](https://github.com/librespot-org/librespot/commit/2eb4aa61d3a14a4f0558991bc96de7cac40302ad) Use single program on events, and pass events in envars. - [`93af49a`](https://github.com/librespot-org/librespot/commit/93af49aadf4164a0e8637b54dc1052dc77b67035) Send player event messages over futures aware channel. - [`23d3c15`](https://github.com/librespot-org/librespot/commit/23d3c1593f078372c7e37fb7d2f70a2607973a34) Just spawn event handlers, don't wait for exit code. ### 📊 Changes **4 files changed** (+130 additions, -72 deletions) <details> <summary>View changed files</summary> 📝 `playback/src/config.rs` (+1 -5) 📝 `playback/src/player.rs` (+72 -61) 📝 `src/main.rs` (+24 -6) ➕ `src/player_event_handler.rs` (+33 -0) </details> ### 📄 Description This PR introduces two changes: * onstop is run when a new song is loaded, if we were already playing * onstart is run when a new song is loaded, if we also start playing it The previous behaviour was that onstop/onstart were only run if the state went from playing => !playing or !playing => playing. The new behaviour is useful for scripts where you want to run a script on every new song. I would argue that there is a brief stop between two songs, so the names still make sense :) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 20:00:04 +03:00
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/librespot#814
No description provided.