audio.html 2.12 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
6
7
8
9
10
11
12
13
14
15
	<div class="controls huge">
		<button class="icon-plus-sign"
			title="Add to playlist" 
			data-player-audio="#Audio-{{ sound.file.url|slugify }}" 
			data-player-method="add" 
			id="addToPlaylist-{{ sound.file.url|slugify }}"
			></button>
		<button class="icon-play-circle"
			title="Play" 
			data-player-audio="#Audio-{{ sound.file.url|slugify }}" 
			data-player-method="play" 
			></button>
Simon Daron's avatar
Simon Daron committed
16
		{% if sound|is_format_available:'ogg' %}
Simon Daron's avatar
Simon Daron committed
17
18
			<a target="_blanck" class="icon-download button" href="{{ sound|format_url:'ogg' }}"
				></a>
Simon Daron's avatar
Simon Daron committed
19
		{% endif %}
Simon Daron's avatar
Simon Daron committed
20
	</div>
Simon Daron's avatar
Simon Daron committed
21
	<audio 
Simon Daron's avatar
Simon Daron committed
22
		data-player='true'
Simon Daron's avatar
Simon Daron committed
23
		class='hidden'
Simon Daron's avatar
Simon Daron committed
24
		title="{{episode.title}}"
Simon Daron's avatar
Simon Daron committed
25
		id="Audio-{{ sound.file.url|slugify }}" 
Simon Daron's avatar
Simon Daron committed
26
		preload="{% if preload %}{{ preload }}{% else %}none{% endif %}"
Simon Daron's avatar
Simon Daron committed
27
28
		controls="{% if controls %}{{ controls }}{% else %}controls{% endif%}"
		>
Simon Daron's avatar
Simon Daron committed
29
		{% if sound|is_format_available:'ogg' %}
Simon Daron's avatar
Simon Daron committed
30
31
			<source src="{{ sound|format_url:'ogg' }}" type="audio/ogg">
		{% endif %}
Simon Daron's avatar
Simon Daron committed
32
		{% if sound|is_format_available:'mp3' %}
Simon Daron's avatar
Simon Daron committed
33
34
			<source src="{{ sound|format_url:'mp3' }}" type="audio/mpeg">
		{% endif %}
35
36
37
38
39
40
41
42
43
44
		<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
45
46
47
48
49
50
51
52
53
54
55
56
57
		<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>
Simon Daron's avatar
Simon Daron committed
58
	
Simon Daron's avatar
Simon Daron committed
59
{% else %}
60
	<div class="error">No sound available!</div>
Simon Daron's avatar
Simon Daron committed
61
{% endif%}