diff --git a/cms/models.py b/cms/models.py index a173439..36c639a 100644 --- a/cms/models.py +++ b/cms/models.py @@ -476,7 +476,10 @@ class DiffusionPage(Publication): return item def get_archive(self): - if not self.publish_archive: + """ + Return the diffusion's archive as podcast + """ + if not self.publish_archive or not self.diffusion: return sound = self.diffusion.get_archives() \ @@ -501,10 +504,9 @@ class DiffusionPage(Publication): podcast.detail_url = self.url return podcasts - def save(self, *args, **kwargs): - # TODO: update public attribute of the archive + podcasts check if live if self.diffusion: + # sync date self.date = self.diffusion.start # update podcasts' attributes diff --git a/cms/static/cms/js/player.js b/cms/static/cms/js/player.js index 26ec4f5..854aa67 100644 --- a/cms/static/cms/js/player.js +++ b/cms/static/cms/js/player.js @@ -78,6 +78,9 @@ PlayerPlaylist.prototype = { item.querySelector('.action.remove').addEventListener( 'click', function(event) { self.remove(sound); }, false ); + item.addEventListener('click', function(event) { + self.player.select(sound, true) + }, false); (container || this.playlist).appendChild(item); this.items.push(sound); @@ -218,6 +221,11 @@ Player.prototype = { sound.item.removeAttribute('selected'); }, + __mime_type: function(path) { + ext = path.substr(path.lastIndexOf('.')+1); + return 'audio/' + ext; + }, + select: function(sound, play = true) { if(this.sound) this.unselect(this.sound); @@ -225,20 +233,17 @@ Player.prototype = { this.audio.pause(); // if stream is a list, use - if(sound.stream.splice) { - this.audio.src=""; - - var sources = this.audio.querySelectorAll('source'); - for(var i in sources) - this.audio.removeChild(sources[i]); - - for(var i in sound.stream) { - var source = document.createElement('source'); - source.src = sound.stream[i]; - } + var sources = this.audio.querySelectorAll('source'); + for(var i = 0; i < sources.length; i++) { + this.audio.removeChild(sources[i]); + } + + sources = sound.stream.splice ? sound.stream : [ sound.stream ]; + for(var i = 0; i < sources.length; i++) { + var source = document.createElement('source'); + source.src = sources[i]; + this.audio.appendChild(source); } - else - this.audio.src = sound.stream; this.audio.load(); this.sound = sound; diff --git a/cms/templates/cms/snippets/sound_list_item.html b/cms/templates/cms/snippets/sound_list_item.html index 7a5d766..aba990b 100644 --- a/cms/templates/cms/snippets/sound_list_item.html +++ b/cms/templates/cms/snippets/sound_list_item.html @@ -4,7 +4,7 @@ + stream='{{ item.url }}'));">

{{ item.name }}

{{ duration.date|date:'H:i:s' }}