public function isPlayable() { if ($this->playable === null) { $this->playable = MimeType::isPlayable($this->getMimeType()); } return $this->playable; }
protected function playFile(Request $request, FileManager $fileManager) { if (!$request->query->has('path')) { return $this->abort(400); } $path = $fileManager->getAbsolutePath($request->query->get('path')); if (!is_file($path)) { return $this->abort(404); } $mimeType = FileUtils::getMimeType($path); if (!MimeType::isPlayable($mimeType)) { return $this->abort(500, 'error.notPlayable'); } $relativePath = $fileManager->getRelativePath($path); $breadcrumb = self::getBreadcrumb($fileManager, $path, false); $name = pathinfo($relativePath, PATHINFO_BASENAME); if (MimeType::isAudio($mimeType)) { $mediaTag = "audio"; } elseif (MimeType::isVideo($mimeType)) { $mediaTag = "video"; } return $this->render(['name' => $name, 'breadcrumb' => $breadcrumb, 'mediaTag' => $mediaTag, 'type' => explode(";", $mimeType)[0], 'src' => $relativePath]); }