audio.html 2.39 KB
Newer Older
Simon Daron's avatar
Simon Daron committed
1
{% load soundfiles %}
Simon Daron's avatar
Simon Daron committed
2
{% load paniktags %}
Simon Daron's avatar
Simon Daron committed
3
{% if sound|is_format_available:'mp3' or sound|is_format_available:'ogg' %}
Simon Daron's avatar
Simon Daron committed
4
5
	<!--
	<span class="controls audioControls" data-audio-control="Audio-{{ sound.file.url|slugify }}">
Simon Daron's avatar
Simon Daron committed
6
		<button class="add icon-plus">{{ sound.content_types }}</button>
Simon Daron's avatar
Simon Daron committed
7
8
		<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>
Simon Daron's avatar
Simon Daron committed
9
10
11
12
13
14
15

		{% if sound|is_format_available:'ogg' %}
			<a class="icon-download" href="{{ sound.url }}"> ogg</a>
		{% endif %}
		{% if sound|is_format_available:'mp3' %}
			<a class="icon-download" href="{{ sound.url }}"> mp3</a>
		{% endif %}
Simon Daron's avatar
Simon Daron committed
16
17
	</span>
	-->
Simon Daron's avatar
Simon Daron committed
18

Simon Daron's avatar
Simon Daron committed
19
	<audio 
Simon Daron's avatar
Simon Daron committed
20
		data-player='true'
Simon Daron's avatar
Simon Daron committed
21
		title="{{episode.title}}"
Simon Daron's avatar
Simon Daron committed
22
		id="Audio-{{ sound.file.url|slugify }}" 
Simon Daron's avatar
Simon Daron committed
23
		preload="{% if preload %}{{ preload }}{% else %}none{% endif %}"
Simon Daron's avatar
Simon Daron committed
24
25
		controls="{% if controls %}{{ controls }}{% else %}controls{% endif%}"
		>
Simon Daron's avatar
Simon Daron committed
26
		{% if sound|is_format_available:'ogg' %}
Simon Daron's avatar
Simon Daron committed
27
28
			<source src="{{ sound|format_url:'ogg' }}" type="audio/ogg">
		{% endif %}
Simon Daron's avatar
Simon Daron committed
29
		{% if sound|is_format_available:'mp3' %}
Simon Daron's avatar
Simon Daron committed
30
31
			<source src="{{ sound|format_url:'mp3' }}" type="audio/mpeg">
		{% endif %}
32
33
34
35
36
37
38
39
40
41
		<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>
Simon Daron's avatar
Simon Daron committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
		<code class="source hidden json">
		{
			"source" :{
				"audio/ogg":{% if sound|is_format_available:'ogg' %}{{ sound|format_url:'ogg'|jsonify|safe }}{% else %}false{% endif %},	
				"audio/mpeg":{% if sound|is_format_available:'mp3' %}{{ sound|format_url:'mp3'|jsonify|safe }}{% else %}false{% endif %}						
			},
			"emission": "{{episode.slug}}",
			"episode": "{{episode.slug}}",
			"title": {{episode.title|jsonify|safe}},
			"id":"{{ sound.file.url|slugify }}"
		}
		</code>
	</audio>
	<button data-playlist-add="#Audio-{{ sound.file.url|slugify }}" class="icon-plus" id="addToPlaylist-{{ sound.file.url|slugify }}">Add to playlist</button>
Simon Daron's avatar
Simon Daron committed
56
{% else %}
57
	<div class="error">No sound available!</div>
Simon Daron's avatar
Simon Daron committed
58
{% endif%}