public function notifyNowPlaying(SSLTrack $track = null) { $nicecastOutput = <<<EOF Title: {$track->getTitle()} Artist: {$track->getArtist()} Album: {$track->getAlbum()} Time: {$track->getLength()} EOF; file_put_contents($this->getFilename(), $nicecastOutput); }
public function notifyScrobble(SSLTrack $track) { $length = $track->getLengthInSeconds(SSLTrack::TRY_HARD); if ($length == 0) { // Perhaps this entry was added manually. L::level(L::WARNING) && L::log(L::WARNING, __CLASS__, 'Could not guess length. Last.fm will silently ignore the scrobble.', array()); } try { $this->scrobbler->add($track->getArtist(), $track->getTitle(), $track->getAlbum(), $length, $track->getStartTime()); L::level(L::DEBUG) && L::log(L::DEBUG, __CLASS__, 'Sending %d scrobble(s) to Last.fm', array($this->scrobbler->getQueueSize())); $this->scrobbler->submit(); // TODO: caching if scrobbling's down whilst playing. } catch (Exception $e) { L::level(L::WARNING) && L::log(L::WARNING, __CLASS__, 'Could not send %d scrobble(s) to Last.fm: %s', array($this->scrobbler->getQueueSize(), $e->getMessage())); } }
/** * It's an SQL error to provide the wrong number variable bindings to a prepared * statement, so we must trim down the number we pass based on which actually * appeared in the SQL statement. */ protected function getPlaceholdersFromTrack(SSLTrack $track, array $placeholder_map) { $placeholders = array(); if ($placeholder_map[':track']) { $placeholders[':track'] = $track->getFullTitle(); } if ($placeholder_map[':artist']) { $placeholders[':artist'] = $track->getArtist(); } if ($placeholder_map[':title']) { $placeholders[':title'] = $track->getTitle(); } if ($placeholder_map[':album']) { $placeholders[':album'] = $track->getAlbum(); } if ($placeholder_map[':key']) { $placeholders[':key'] = $this->key; } return $placeholders; }