mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Run onstart/onstop when a new song is loaded
This commit is contained in:
parent
1257f98915
commit
77bea07c4f
1 changed files with 2 additions and 10 deletions
|
@ -288,14 +288,13 @@ impl PlayerInternal {
|
||||||
PlayerCommand::Load(track_id, play, position, end_of_track) => {
|
PlayerCommand::Load(track_id, play, position, end_of_track) => {
|
||||||
if self.state.is_playing() {
|
if self.state.is_playing() {
|
||||||
self.stop_sink_if_running();
|
self.stop_sink_if_running();
|
||||||
|
self.run_onstop();
|
||||||
}
|
}
|
||||||
|
|
||||||
match self.load_track(track_id, position as i64) {
|
match self.load_track(track_id, position as i64) {
|
||||||
Some(decoder) => {
|
Some(decoder) => {
|
||||||
if play {
|
if play {
|
||||||
if !self.state.is_playing() {
|
self.run_onstart();
|
||||||
self.run_onstart();
|
|
||||||
}
|
|
||||||
self.start_sink();
|
self.start_sink();
|
||||||
|
|
||||||
self.state = PlayerState::Playing {
|
self.state = PlayerState::Playing {
|
||||||
|
@ -303,10 +302,6 @@ impl PlayerInternal {
|
||||||
end_of_track: end_of_track,
|
end_of_track: end_of_track,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
if self.state.is_playing() {
|
|
||||||
self.run_onstop();
|
|
||||||
}
|
|
||||||
|
|
||||||
self.state = PlayerState::Paused {
|
self.state = PlayerState::Paused {
|
||||||
decoder: decoder,
|
decoder: decoder,
|
||||||
end_of_track: end_of_track,
|
end_of_track: end_of_track,
|
||||||
|
@ -316,9 +311,6 @@ impl PlayerInternal {
|
||||||
|
|
||||||
None => {
|
None => {
|
||||||
let _ = end_of_track.send(());
|
let _ = end_of_track.send(());
|
||||||
if self.state.is_playing() {
|
|
||||||
self.run_onstop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue