{% load i18n %}
{% comment %}
The audio player
{% endcomment %}

{% if audio_streams %}
<br>

<div class="box is-fullwidth is-fixed-bottom is-paddingless player"
    role="{% trans "player" %}"
    aria-description="{% trans "Audio player used to listen to the radio and podcasts" %}">
    <noscript>
        <audio src="{{ audio_streams.0 }}" controls>
            {% for stream in audio_streams %}
            <source src="{{ stream }}" />
            {% endfor %}
        </audio>
        {# TODO: live infos #}
    </noscript>

    <a-player ref="player" src="{{ audio_streams.0 }}"
            live-info-url="{% url "api:live" %}" :live-info-timeout="20"
            button-title="{% trans "Play or pause audio" %}">
        <template v-slot:sources>
            {% for stream in audio_streams %}
            <source src="{{ stream }}" />
            {% endfor %}
        </template>

        <template v-slot:track="{ onAir }">
            <h4 class="title is-4">
                <span class="has-text-info is-size-3">&#9836;</span>
                <span>[[ onAir.title ]]</span>
                <span class="has-text-grey-dark has-text-weight-light">
                &mdash; [[ onAir.artist ]]
                <i v-if="onAir.info">([[ onAir.info ]])</i>
                </span>
            </h4>
        </template>

        <template v-slot:diffusion="{ onAir }">
            <h4 class="title is-4">
                <a :href="onAir.url">[[ onAir.title ]]</a>
            </h4>
            <div class="">[[ onAir.info ]]</div>
        </template>

        <template v-slot:empty>
            <h4 class="title is-4">{{ station.name }}</h4>
        </template>
    </a-player>
</div>
{% endif %}

