Commit 38b5d7b2 authored by Simon Daron's avatar Simon Daron

Add some json meta info to audio

parent f66d8e64
......@@ -3,6 +3,8 @@ import urllib2
import uuid
from django import template
from django.db.models.query import QuerySet
from django.utils import simplejson
register = template.Library()
......@@ -10,9 +12,10 @@ register = template.Library()
def zip_lists(a, b):
return zip(a, b)
@register.inclusion_tag('includes/audio.html')
def audio(sound=None):
@register.inclusion_tag('includes/audio.html', takes_context=True)
def audio(context, sound=None):
return {
'episode': context.get('episode'),
'sound': sound
}
......@@ -49,6 +52,12 @@ def news_inline(content=None, klass=None, logo=None):
}
@register.filter
def jsonify(object):
if isinstance(object, QuerySet):
return serialize('json', object)
return simplejson.dumps(object)
@register.filter
def remove_tag_facet(url, facet):
facet = urllib2.quote(facet.encode('utf-8'), safe='')
......
$(function() {
$(function() {
var $main = $("#Changing");
var $log = $("#userLog");
doLog = function(aTextToLog, type){
......@@ -85,24 +85,38 @@ $(function() {
});
});
$("[data-audio-control]").each(function() {
var playPauseButton = $(this).find('.playpause');
var audio = $('#'+$(this).attr('data-audio'));
var audio = $('#'+$(this).attr('data-audio-control'));
var audioElement = audio[0];
//alert($(this).attr('data-audio'));
playPauseButton.on('click',function(e){
if (audioElement.paused == false) {
audioElement.pause();
} else {
audioElement.play();
}
});
// Bind back event in case of direct control
audio.on('play',function(){
playPauseButton.addClass('icon-pause').removeClass('icon-play');
}).on('pause',function(){
playPauseButton.addClass('icon-play').removeClass('icon-pause');
});
if(audioElement){
var addToPlaylist = $(this).find('.add');
addToPlaylist.on('click',function(e){
audio.clone().appendTo('#Playlist');
$('#Playlist').parent().show();
});
var playPauseButton = $(this).find('.playpause');
//alert($(this).attr('data-audio'));
playPauseButton.on('click',function(e){
if (audioElement.paused == false) {
audioElement.pause();
} else {
audioElement.play();
}
});
//alert($(this).attr('data-audio'));
playPauseButton.on('click',function(e){
if (audioElement.paused == false) {
audioElement.pause();
} else {
audioElement.play();
}
});
// Bind back event in case of direct control
audio.on('play',function(){
playPauseButton.addClass('icon-pause').removeClass('icon-play');
}).on('pause',function(){
playPauseButton.addClass('icon-play').removeClass('icon-pause');
});
}
});
}
init();
......
......@@ -33,6 +33,12 @@
<h5 class="title ellipsis smooth">{{ episode.emission.title }}</h5>
{% endif %}
<h5 class="title"><a href="{% url 'episode-view' emission_slug=episode.emission.slug slug=episode.slug %}">{{ episode.title }}</a></h5>
{% if episode.main_sound %}
<div class="sound">
{% audio sound=episode.main_sound %}
</div>
{% endif %}
{% if model = "inline" %}
{% if episode.description %}
<div class="description ellipsis">
......@@ -70,10 +76,5 @@
</ul>
{% endif %}
</div>
{% if episode.main_sound %}
<div class="sound">
{% audio sound=episode.main_sound %}
</div>
{% endif %}
</div>
</div>
{% load soundfiles %}
{% load paniktags %}
{% if sound|is_format_available:'mp3' or sound|is_format_available:'ogg' %}
<!--
<span class="controls audioControls" data-audio-control="Audio-{{ sound.file.url|slugify }}">
<button class="add icon-plus">{{ sound.content_types }}</button>
<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>
{% 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 %}
</span>
-->
<audio
data-player='true'
data-metas='{"episode":{{episode.title|jsonify}}}'
id="Audio-{{ sound.file.url|slugify }}"
preload="{% if preload %}{{ preload }}{% else %}none{% endif %}"
controls="{% if controls %}{{ controls }}{% else %}controls{% endif%}"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment