static function getInfo($mid, $opt = null) { ///// Voice if (preg_match("/v([\\d]+)/", $mid, $matches)) { $id = intval($matches[1]); $voiceDb = new VoiceInfoDB(); $info = $voiceDb->getInfo($id); if ($info && $opt['detail']) { $voiceDb->getDetail($info); } if ($info && $opt['playing']) { $voiceDb->getPlaying($info); } return $info; } return null; }
function handle() { if (is_a($this->info, 'VoiceInfo')) { $path = $this->info->dst; if (!file_exists($path)) { throw new VoiceException(self::ERROR_NO_FILE); } $voiceDb = new VoiceInfoDB(); $voiceDb->getPlaying($this->info); $this->info->playedCount++; $voiceDb->updatePlaying($this->info); //header('Cache-Control: public'); header('Content-type: audio/mpeg'); header('Accept-Ranges: bytes'); header('Content-Length: ' . filesize($path)); readfile($path); } }
function testUpdatePlaying() { $info = new VoiceInfo($this->data); $infoSub = new VoiceInfo($this->dataSub); $store = new VoiceInfoDB(); $store->updatePlaying($infoSub); $result = $store->getPlaying($infoSub); $this->assertSame(-998, $result->playedCount); $store->updatePlaying($info); $result = $store->getPlaying($info); $this->assertSame(-999, $result->playedCount); }