audio.html 2.24 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
	<div class="controls huge">
Simon Daron's avatar
Simon Daron committed
5
		<button class="resymbol icon-plus-sign"
Simon Daron's avatar
Simon Daron committed
6
			title="Add to playlist" 
Simon Daron's avatar
Simon Daron committed
7
8
			data-player-audio="Audio-{{ sound.file.url|slugify }}" 
			data-player-action="registerAudio" 
Simon Daron's avatar
Simon Daron committed
9
10
			id="addToPlaylist-{{ sound.file.url|slugify }}"
			></button>
Simon Daron's avatar
Simon Daron committed
11
		<button class="resymbol icon-play"
Simon Daron's avatar
Simon Daron committed
12
			title="Play" 
Simon Daron's avatar
Simon Daron committed
13
14
			data-player-audio="Audio-{{ sound.file.url|slugify }}" 
			data-player-action="playAudio" 
Simon Daron's avatar
Simon Daron committed
15
			></button>
Simon Daron's avatar
Simon Daron committed
16
		{% if sound|is_format_available:'ogg' %}
Simon Daron's avatar
Simon Daron committed
17
			<a target="_blanck" class="resymbol icon-download button" href="{{ sound|format_url:'ogg' }}"
Simon Daron's avatar
Simon Daron committed
18
				></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'
24
		data-url="{% url 'episode-view' emission_slug=episode.emission.slug slug=episode.slug %}"
Simon Daron's avatar
Simon Daron committed
25
		title="{{episode.title}}"
Simon Daron's avatar
Simon Daron committed
26
		id="Audio-{{ sound.file.url|slugify }}" 
Simon Daron's avatar
Simon Daron committed
27
		preload="{% if preload %}{{ preload }}{% else %}none{% endif %}"
Simon Daron's avatar
Simon Daron committed
28
29
		controls="{% if controls %}{{ controls }}{% else %}controls{% endif%}"
		>
Simon Daron's avatar
Simon Daron committed
30
		{% if sound|is_format_available:'ogg' %}
Simon Daron's avatar
Simon Daron committed
31
32
			<source src="{{ sound|format_url:'ogg' }}" type="audio/ogg">
		{% endif %}
Simon Daron's avatar
Simon Daron committed
33
		{% if sound|is_format_available:'mp3' %}
Simon Daron's avatar
Simon Daron committed
34
35
			<source src="{{ sound|format_url:'mp3' }}" type="audio/mpeg">
		{% endif %}
36
37
38
39
40
41
42
43
44
45
		<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
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>
Simon Daron's avatar
Simon Daron committed
58
	</audio>	
Simon Daron's avatar
Simon Daron committed
59
{% else %}
Simon Daron's avatar
Simon Daron committed
60
	<div class="hidden error">No sound available!</div>
Simon Daron's avatar
Simon Daron committed
61
{% endif%}