diff --git a/lib/Pi/View/Helper/Videojs.php b/lib/Pi/View/Helper/Videojs.php index a72cd3c122..22ecad0353 100644 --- a/lib/Pi/View/Helper/Videojs.php +++ b/lib/Pi/View/Helper/Videojs.php @@ -18,6 +18,7 @@ * * Usage inside a phtml template * + * $this->videojs($source); * $this->videojs($source, $poster); * $this->videojs($source, $poster, $width, $height); * @@ -39,22 +40,55 @@ class Videojs extends AbstractHtmlElement * * @return string */ - public function __invoke($source, $poster, $width = 640, $height = 264) + public function __invoke($source, $poster = '', $width = '', $height = '') { - // Set template + // Get media extension $extension = pathinfo($source, PATHINFO_EXTENSION); + + // Set template switch ($extension) { + case 'mp3': + // Set player poster + if (empty($poster)) { + $image = Pi::path('upload/video-js/audio.jpg'); + if (Pi::service('file')->exists($image)) { + $poster = Pi::url('upload/video-js/audio.jpg'); + } else { + $poster = Pi::url('static/vendor/video-js/image/audio.jpg'); + } + } + + // Set player width and height + $width = !empty($width) ? $width : 1280; + $height = !empty($height) ? $height : 180; + + // Set html template $template = <<<'EOT' -