/** * Sets a track from a ScrobblerTrackModel as "now playing", and notifies observers * * @param ScrobblerTrackModel $scrobble_model */ protected function setTrackNowPlaying(ScrobblerTrackModel $scrobble_model) { $candidate_now_playing_track = $scrobble_model->getTrack(); $new_track = false; // is this a "new" now playing track? if (!empty($this->now_playing_in_queue)) { $np_row = $this->now_playing_in_queue->getRow(); $cd_row = $candidate_now_playing_track->getRow(); if ($np_row != $cd_row) { $new_track = true; } } else { $new_track = true; } if ($new_track) { // There is a new track playing! // keep the now playing model $this->now_playing_in_queue = $scrobble_model; // notify observers (Growl, etc) $this->notifyNowPlayingObservers($candidate_now_playing_track); } }