]> git.0d.be Git - panikweb.git/blobdiff - panikweb_templates/templates/includes/audio.html
add rel="noopener" to links opening in new tabs
[panikweb.git] / panikweb_templates / templates / includes / audio.html
index f01ea78e3e1f9aed6b3ed28db47d5b61c3f78a8a..673452d4aed07d25615a5d586d6f2efc6e6de295 100644 (file)
@@ -1,24 +1,84 @@
-{% load soundfiles %}
-{% if sound %}
-       <!--
-       <span class="controls audioControls" data-audio-control="Audio-{{ sound.file.url|slugify }}">
-               <button class="playpause icon-play">{{ sound.content_types }}</button>
-               <button class="icon-eye-open" title="Show/Hidden HTML5 audio player" onclick="$('#Audio-{{ sound.file.url|slugify }}').toggleClass('hidden');$(this).toggleClass('icon-eye-open icon-eye-close');return false;"></button>
-               <a class="icon-download" href="{{ sound.url }}"></a>
-       </span>
-       -->
-       <audio 
-               id="Audio-{{ sound.file.url|slugify }}" 
-               preload="{% if preload %}{{ preload }}{% else %}false{% endif %}"
+{% load soundfiles paniktags i18n %}
+{% if sound|is_format_available:'mp3' or sound|is_format_available:'ogg' %}
+       <div class="audio" data-sound-id="{{ sound.id }}">
+               {% if not embed %}
+               <button class="resymbol icon-plus-sign big"
+                       title="{% trans "Add to playlist" %}"
+                       data-sound-id="{{ sound.id }}"
+                       data-player-audio="Audio-{{ sound.file.url|slugify }}" 
+                       data-player-action="registerAudio" 
+                       ><span class="sr-only">{% trans "Add to playlist" %}</span></button>
+               {% endif %}
+               <button class="resymbol icon-play-sign big"
+                       title="{% trans "Play" %}"
+                       data-sound-id="{{ sound.id }}"
+                       data-player-action="playAudio" 
+                       ><span class="sr-only">{% trans "Play" %}</span></button>
+               {% if embed %}
+               <button class="icons icon-pause big"
+                       title="{% trans "Pause" %}"
+                       style="display: none;"
+                       data-sound-id="{{ sound.id }}"
+                       data-player-action="pauseSounds" 
+                       ><span class="sr-only">{% trans "Pause" %}</span></button>
+               {% endif %}
+               <button class="resymbol icon-download big"
+                       title="{% trans "Download file" %}"
+                       onclick="$(this).next().toggleClass('hidden-download-links');return false;"
+                       ><span class="sr-only">{% trans "Download file" %}</span></button>
+               <div class="download-links hidden-download-links">
+                       {% if sound|is_format_available:'ogg' %}
+                       <a target="_blank" rel="noopener" class="button inBlock" href="{{ sound|format_url:'ogg' }}">
+                               <span class="icon-file">&nbsp;ogg</span>
+                       </a>
+                       {% endif %}
+                       {% if sound|is_format_available:'mp3' %}
+                       <a target="_blank" rel="noopener" class="button inBlock" href="{{ sound|format_url:'mp3' }}">
+                               <span class="icon-file">&nbsp;mp3</span>
+                       </a>
+                       {% endif %}
+               </div>
+               {% if not embed %}
+               <button class="icon-share icons big"
+                       title="{% trans "Embed" %}"
+                       data-popup-href="{% url 'soundfile-dialog-embed-view' emission_slug=sound.episode.emission.slug episode_slug=sound.episode.slug pk=sound.pk %}"
+                       ><span class="sr-only">{% trans "Embed" %}</span></button>
+               {% endif %}
+       </div>
+       {% if display_fragment_name %}
+       <div class="fragment-name">
+               {{ sound.title }}
+       </div>
+       {% endif %}
+       <audio
+               data-player='true'
+               class='hidden'
+               data-url="{% url 'episode-view' emission_slug=sound.episode.emission.slug slug=sound.episode.slug %}"
+               data-sound-id="{{ sound.id }}"
+               {% if sound.fragment and sound.title %}title="{{ sound.title }}"
+               {% else %}title="{{sound.episode.title}}"{% endif %}
+               preload="{% if preload %}{{ preload }}{% else %}none{% endif %}"
                controls="{% if controls %}{{ controls }}{% else %}controls{% endif%}"
                >
-               {% if episode.main_sound|is_format_available:'ogg' %}
+               {% if sound|is_format_available:'ogg' %}
                        <source src="{{ sound|format_url:'ogg' }}" type="audio/ogg">
                {% endif %}
-               {% if episode.main_sound|is_format_available:'mp3' %}
+               {% if sound|is_format_available:'mp3' %}
                        <source src="{{ sound|format_url:'mp3' }}" type="audio/mpeg">
                {% endif %}
-       </audio>  
+               <div class="alternative padded">
+                       <div class="info smooth">Your browser can't play audio files</div>
+                       <strong>Download: </strong>
+                       {% if sound|is_format_available:'ogg' %}
+                               <a class="icon-headphones" href="{{ sound|format_url:'ogg' }}"> ogg</a>
+                       {% endif %}
+                       {% if sound|is_format_available:'mp3' %}
+                               <a class="icon-headphones" href="{{ sound|format_url:'mp3' }}"> mp3</a>
+                       {% endif %}
+               </div>
+       </audio>
+       <div class="waveform" data-sound-id="{{ sound.id }}" data-duration="{{ sound.duration }}"
+               data-duration-string="{{ sound.get_duration_string }}"></div>
 {% else %}
-       <div class="icon-ban-circle ">No sound!</div>
+       <div class="hidden error">No sound available!</div>
 {% endif%}