forked from rc/aircox
make player working
This commit is contained in:
parent
801a89e503
commit
ac3705d401
|
@ -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
|
||||
|
|
|
@ -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 <source>
|
||||
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;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<a class="list_item sound" onclick="player.playlist.add(new Sound(
|
||||
title='{{ item.name|escape }}',
|
||||
detail='{{ item.detail_url }}',
|
||||
stream='{% static item.path %}'));">
|
||||
stream='{{ item.url }}'));">
|
||||
<h3>{{ item.name }}</h3>
|
||||
<span class="info">
|
||||
{{ duration.date|date:'H:i:s' }}
|
||||
|
|
Loading…
Reference in New Issue
Block a user