/** * @return SSLDom */ protected function read($filename) { $parser = $this->factory->newParser($this->newDom()); $tree = $parser->parse($filename); $parser->close(); return $tree; }
protected function trackStopped(SSLTrack $track) { $stm = $this->factory->newScrobblerTrackModel($track); if ($stm->isScrobblable()) { L::level(L::INFO) && L::log(L::INFO, __CLASS__, 'I reckon it\'s time to submit a scrobble for %s!', array($track->getFullTitle())); $this->notifyScrobbleObservers($track); } }
public function readChunks() { if (!$this->fp) { throw new RuntimeException("readChunks() called with no file open."); } $reader = $this->factory->newChunkReader($this->fp); $dom = clone $this->dom_prototype; $dom->addChunks($reader->getChunks()); return $dom; }
protected function startTrack(SSLTrack $started_track) { $started_row = $started_track->getRow(); foreach ($this->now_playing_queue as $i => $scrobble_model) { /* @var $scrobble_model ScrobblerTrackModel */ if ($scrobble_model->getRow() == $started_row) { // do not double-add to the queue. return; } } // Put new tracks last in the queue for the purposes of determining what's now playing. // This means that tracks should transition to "Now Playing" when the previous track is stopped or taken off the deck. $scrobble_model = $this->factory->newScrobblerTrackModel($started_track); $scrobble_model_row = $scrobble_model->getRow(); if ($scrobble_model_row != $started_row) { throw new RuntimeException("Row mismatch! Asked for {$started_row}, got {$scrobble_model_row}"); } $this->now_playing_queue[] = $scrobble_model; L::level(L::INFO) && L::log(L::INFO, __CLASS__, 'enqueued track %s', array($started_track->getFullTitle())); L::level(L::DEBUG) && L::log(L::DEBUG, __CLASS__, 'queue length is now %d', array(count($this->now_playing_queue))); }
/** * Eject stuff from the decks and send final notifications. */ public function shutdown() { $events = array(); foreach ($this->decks as $deck_number => $deck) { /* @var $deck SSLRealtimeModelDeck */ $track = $deck->getCurrentTrack(); if ($track) { $events[] = $this->factory->newTrackStoppedEvent($track); } } $events = $this->factory->newTrackChangeEventList($events); $this->notifyTrackChangeObservers($events); }
public function newScrobblerTrackModel(SSLTrack $track) { $this->call_count++; $track_row = $track->getRow(); $this->decks[$track_row] = parent::newScrobblerTrackModel($track); return $this->decks[$track_row]; }
public function newTrack() { return $this->factory->newRuntimeCachingTrack($this); }
/** * Reads an SSL data file chunk from the filepointer. Chunks have an 8 byte header * consisting of 4 byte type string and 4 byte length. * * @return SSLChunk */ protected function readChunk() { $cp = $this->factory->newChunkParser(); return $cp->parseFromFile($this->fp); }