break; case 'play': $ftype = \OC\Files\Filesystem::getMimeType($arguments['path']); if (substr($ftype, 0, 5) != 'audio' and $ftype != 'application/ogg') { echo 'Not an audio file'; exit; } $songId = $collection->getSongByPath($arguments['path']); $collection->registerPlay($songId); header('Content-Type:' . $ftype); \OCP\Response::enableCaching(3600 * 24); // 24 hour header('Accept-Ranges: bytes'); header('Content-Length: ' . \OC\Files\Filesystem::filesize($arguments['path'])); $mtime = \OC\Files\Filesystem::filemtime($arguments['path']); \OCP\Response::setLastModifiedHeader($mtime); \OC\Files\Filesystem::readfile($arguments['path']); exit; case 'find_music': $scanner = new Scanner($collection); $music = $scanner->getMusic(); \OCP\JSON::encodedPrint($music); exit; } } class ScanWatcher { /** * @var \OC_EventSource $eventSource; */ private $eventSource;
public function show() { if ($this->useOriginal) { $fp = @$this->view->fopen($this->path, 'rb'); $mtime = $this->view->filemtime($this->path); $size = $this->view->filesize($this->path); $mime = $this->view->getMimetype($this->path); } else { $fp = @fopen($this->path, 'rb'); $mtime = filemtime($this->path); $size = filesize($this->path); $mime = \OC_Helper::getMimetype($this->path); } if ($fp) { \OCP\Response::enableCaching(); \OCP\Response::setLastModifiedHeader($mtime); header('Content-Length: ' . $size); header('Content-Type: ' . $mime); fpassthru($fp); } else { \OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND); } }
/** * Get the thumbnail of the image * @param string $thumbImagePath */ public function getThumbnail($thumbImagePath) { $fp = @fopen($thumbImagePath, 'rb'); $mtime = filemtime($thumbImagePath); $size = filesize($thumbImagePath); $mime = \OC_Helper::getMimetype($thumbImagePath); if ($fp) { \OCP\Response::enableCaching(); \OCP\Response::setLastModifiedHeader($mtime); header('Content-Length: ' . $size); header('Content-Type: ' . $mime); fpassthru($fp); } else { \OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND); } }