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

<br>

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

    <a-player ref="player"
            :live-args="{% player_live_attr %}"
            button-title="{% translate "Play or pause audio" %}">
        <template v-slot:content="{ loaded, live, current }">
            <h4 v-if="loaded" class="title is-4">
                [[ loaded.name ]]
            </h4>
            <h4 v-else-if="current && current.data.type == 'track'"
                class="title is-4" aria-description="{% translate "Track currently on air" %}">
                <span class="has-text-info is-size-3">&#9836;</span>
                <span>[[ current.data.title ]]</span>
                <span class="has-text-grey-dark has-text-weight-light">
                &mdash; [[ current.data.artist ]]
                <i v-if="current.data.info">([[ current.data.info ]])</i>
                </span>
            </h4>
            <div v-else-if="live && current && current.data.type == 'diffusion'">
                <h4 class="title is-4" aria-description="{% translate "Diffusion currently on air" %}">
                    <a :href="current.data.url">[[ current.data.title ]]</a>
                </h4>
                <div class="">[[ current.data.info ]]</div>
            </div>
            <h4 v-else class="title is-4" aria-description="{% translate "Currently playing" %}">
                {{ request.station.name }}
            </h4>
        </template>
    </a-player>
</div>
