FluidTYPO3\Vhs\ViewHelpers\Media\VideoViewHelper::render PHP Method

render() public method

Render method
public render ( ) : string
return string
    public function render()
    {
        $sources = $this->getSourcesFromArgument();
        if (0 === count($sources)) {
            throw new Exception('No video sources provided.', 1359382189);
        }
        foreach ($sources as $source) {
            if (true === is_string($source)) {
                if (false !== strpos($source, '//')) {
                    $src = $source;
                    $type = substr($source, strrpos($source, '.') + 1);
                } else {
                    $src = substr(GeneralUtility::getFileAbsFileName($source), strlen(PATH_site));
                    $type = pathinfo($src, PATHINFO_EXTENSION);
                }
            } elseif (true === is_array($source)) {
                if (false === isset($source['src'])) {
                    throw new Exception('Missing value for "src" in sources array.', 1359381250);
                }
                $src = $source['src'];
                if (false === isset($source['type'])) {
                    throw new Exception('Missing value for "type" in sources array.', 1359381255);
                }
                $type = $source['type'];
            } else {
                // skip invalid source
                continue;
            }
            if (false === in_array(strtolower($type), $this->validTypes)) {
                throw new Exception('Invalid video type "' . $type . '".', 1359381260);
            }
            $type = $this->mimeTypesMap[$type];
            $src = $this->preprocessSourceUri($src);
            $this->renderChildTag('source', ['src' => $src, 'type' => $type], false, 'append');
        }
        $tagAttributes = ['width' => $this->arguments['width'], 'height' => $this->arguments['height'], 'preload' => 'auto'];
        if (true === (bool) $this->arguments['autoplay']) {
            $tagAttributes['autoplay'] = 'autoplay';
        }
        if (true === (bool) $this->arguments['controls']) {
            $tagAttributes['controls'] = 'controls';
        }
        if (true === (bool) $this->arguments['loop']) {
            $tagAttributes['loop'] = 'loop';
        }
        if (true === (bool) $this->arguments['muted']) {
            $tagAttributes['muted'] = 'muted';
        }
        if (true === in_array($this->arguments['preload'], $this->validPreloadModes)) {
            $tagAttributes['preload'] = 'preload';
        }
        if (null !== $this->arguments['poster']) {
            $tagAttributes['poster'] = $this->arguments['poster'];
        }
        $this->tag->addAttributes($tagAttributes);
        if (null !== $this->arguments['unsupported']) {
            $this->tag->setContent($this->tag->getContent() . LF . $this->arguments['unsupported']);
        }
        return $this->tag->render();
    }