audio.html 2.7 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' %}
4
5
	<div class="">
		<button class="resymbol icon-plus-sign big"
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>
11
		<button class="resymbol icon-play big"
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>
16
17
18
19
20
			
		<button class="resymbol icon-download big"
			title="Download file" 
			onclick="$('#Download-{{ sound.file.url|slugify }}').toggle();return false;"
			></button>
fred's avatar
fred committed
21
22
23
24
25
26
27
28
29
30
31
32
		<span class="hidden" id="Download-{{ sound.file.url|slugify }}" >
			{% if sound|is_format_available:'ogg' %}
			<a target="_blanck" class="icon-file button" href="{{ sound|format_url:'ogg' }}">
				<span>ogg</span>
			</a>
			{% endif %}
			{% if sound|is_format_available:'mp3' %}
			<a target="_blanck" class="icon-file button" href="{{ sound|format_url:'mp3' }}">
				<span>mp3</span>
			</a>
			{% endif %}
		</span>
Simon Daron's avatar
Simon Daron committed
33
	</div>
Simon Daron's avatar
Simon Daron committed
34
	<audio 
Simon Daron's avatar
Simon Daron committed
35
		data-player='true'
Simon Daron's avatar
Simon Daron committed
36
		class='hidden'
37
38
		data-url="{% url 'episode-view' emission_slug=sound.episode.emission.slug slug=sound.episode.slug %}"
		title="{{sound.episode.title}}"
Simon Daron's avatar
Simon Daron committed
39
		id="Audio-{{ sound.file.url|slugify }}" 
Simon Daron's avatar
Simon Daron committed
40
		preload="{% if preload %}{{ preload }}{% else %}none{% endif %}"
Simon Daron's avatar
Simon Daron committed
41
42
		controls="{% if controls %}{{ controls }}{% else %}controls{% endif%}"
		>
Simon Daron's avatar
Simon Daron committed
43
		{% if sound|is_format_available:'ogg' %}
Simon Daron's avatar
Simon Daron committed
44
45
			<source src="{{ sound|format_url:'ogg' }}" type="audio/ogg">
		{% endif %}
Simon Daron's avatar
Simon Daron committed
46
		{% if sound|is_format_available:'mp3' %}
Simon Daron's avatar
Simon Daron committed
47
48
			<source src="{{ sound|format_url:'mp3' }}" type="audio/mpeg">
		{% endif %}
49
50
51
52
53
54
55
56
57
58
		<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
59
60
61
62
63
64
		<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 %}						
			},
65
66
67
			"emission": "{{sound.episode.emission.slug}}",
			"episode": "{{sound.episode.slug}}",
			"title": {{sound.episode.title|jsonify|safe}},
Simon Daron's avatar
Simon Daron committed
68
69
70
			"id":"{{ sound.file.url|slugify }}"
		}
		</code>
Simon Daron's avatar
Simon Daron committed
71
	</audio>	
Simon Daron's avatar
Simon Daron committed
72
{% else %}
Simon Daron's avatar
Simon Daron committed
73
	<div class="hidden error">No sound available!</div>
Simon Daron's avatar
Simon Daron committed
74
{% endif%}