<!--
    Render a video in an interactive player.

    @params context Video media file.
    @params page_file_path  Filepath of the calling file for error messages.
-->

{{- $src := .src -}}

<video
    class="u-video figure__video"
    controls
    itemprop="video"
    preload="none"
    src="{{ $src.RelPermalink }}"
    poster="
    {{- if $src.Params.poster -}}
        {{- $posterSrc := $.Page.Resources.GetMatch ( .Get $src.Params.poster ) -}}
        {{- with $posterSrc.Resize "1200x webp" -}}
            {{- .RelPermalink -}}
        {{- end -}}
    {{- else -}}
        {{- erroridf "a11y-video-poster" "No poster defined for resource %q (%q)" $src.RelPermalink .page_file_path -}}
    {{- end -}}
    "
>
    Your browser doesn't support embedded video, <a href="{{ $src.RelPermalink }}">view the video here</a>.
</video>