(&mut self, force: bool)
| 172 | |
| 173 | #[tracing::instrument(level = "debug", skip(self))] |
| 174 | pub fn update_current_song(&mut self, force: bool) { |
| 175 | self.data.player_details.last_song_played_duration = self.data.player_details.current_time; |
| 176 | self.data.player_details.last_song = |
| 177 | self.get_current_song().map(|s| s.song._id.unwrap().clone()); |
| 178 | |
| 179 | if self.data.queue.current_index >= self.data.queue.song_queue.len() { |
| 180 | self.data.queue.current_index = 0; |
| 181 | } |
| 182 | let id = self |
| 183 | .data |
| 184 | .queue |
| 185 | .song_queue |
| 186 | .get(self.data.queue.current_index) |
| 187 | .cloned() |
| 188 | .unwrap_or_default(); |
| 189 | |
| 190 | let song = self.data.queue.data.get(&id).cloned(); |
| 191 | |
| 192 | if !force && song == self.data.current_song && self.data.player_blacklist.is_empty() { |
| 193 | return; |
| 194 | } |
| 195 | |
| 196 | tracing::debug!("Upading song in queue"); |
| 197 | self.data.current_song = song.clone(); |
| 198 | if self.data.current_song.is_none() { |
| 199 | self.data.player_details.current_time = 0f64; |
| 200 | } |
| 201 | |
| 202 | self.clear_blacklist(); |
| 203 | |
| 204 | if force { |
| 205 | self.data.force_load_song = !self.data.force_load_song; |
| 206 | } |
| 207 | |
| 208 | self.scrobble_time = 0f64; |
| 209 | self.scrobbled = false; |
| 210 | |
| 211 | self.dump_store(&[DumpType::CurrentIndex, DumpType::PlayerState]); |
| 212 | } |
| 213 | |
| 214 | #[tracing::instrument(level = "debug", skip(self, songs))] |
| 215 | pub fn add_to_queue(&mut self, songs: Vec<Song>) { |
no test coverage detected