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
|
return item
|
||||||
|
|
||||||
def get_archive(self):
|
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
|
return
|
||||||
|
|
||||||
sound = self.diffusion.get_archives() \
|
sound = self.diffusion.get_archives() \
|
||||||
|
@ -501,10 +504,9 @@ class DiffusionPage(Publication):
|
||||||
podcast.detail_url = self.url
|
podcast.detail_url = self.url
|
||||||
return podcasts
|
return podcasts
|
||||||
|
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
# TODO: update public attribute of the archive + podcasts check if live
|
|
||||||
if self.diffusion:
|
if self.diffusion:
|
||||||
|
# sync date
|
||||||
self.date = self.diffusion.start
|
self.date = self.diffusion.start
|
||||||
|
|
||||||
# update podcasts' attributes
|
# update podcasts' attributes
|
||||||
|
|
|
@ -78,6 +78,9 @@ PlayerPlaylist.prototype = {
|
||||||
item.querySelector('.action.remove').addEventListener(
|
item.querySelector('.action.remove').addEventListener(
|
||||||
'click', function(event) { self.remove(sound); }, false
|
'click', function(event) { self.remove(sound); }, false
|
||||||
);
|
);
|
||||||
|
item.addEventListener('click', function(event) {
|
||||||
|
self.player.select(sound, true)
|
||||||
|
}, false);
|
||||||
|
|
||||||
(container || this.playlist).appendChild(item);
|
(container || this.playlist).appendChild(item);
|
||||||
this.items.push(sound);
|
this.items.push(sound);
|
||||||
|
@ -218,6 +221,11 @@ Player.prototype = {
|
||||||
sound.item.removeAttribute('selected');
|
sound.item.removeAttribute('selected');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
__mime_type: function(path) {
|
||||||
|
ext = path.substr(path.lastIndexOf('.')+1);
|
||||||
|
return 'audio/' + ext;
|
||||||
|
},
|
||||||
|
|
||||||
select: function(sound, play = true) {
|
select: function(sound, play = true) {
|
||||||
if(this.sound)
|
if(this.sound)
|
||||||
this.unselect(this.sound);
|
this.unselect(this.sound);
|
||||||
|
@ -225,20 +233,17 @@ Player.prototype = {
|
||||||
this.audio.pause();
|
this.audio.pause();
|
||||||
|
|
||||||
// if stream is a list, use <source>
|
// if stream is a list, use <source>
|
||||||
if(sound.stream.splice) {
|
var sources = this.audio.querySelectorAll('source');
|
||||||
this.audio.src="";
|
for(var i = 0; i < sources.length; i++) {
|
||||||
|
this.audio.removeChild(sources[i]);
|
||||||
var sources = this.audio.querySelectorAll('source');
|
}
|
||||||
for(var i in sources)
|
|
||||||
this.audio.removeChild(sources[i]);
|
sources = sound.stream.splice ? sound.stream : [ sound.stream ];
|
||||||
|
for(var i = 0; i < sources.length; i++) {
|
||||||
for(var i in sound.stream) {
|
var source = document.createElement('source');
|
||||||
var source = document.createElement('source');
|
source.src = sources[i];
|
||||||
source.src = sound.stream[i];
|
this.audio.appendChild(source);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
this.audio.src = sound.stream;
|
|
||||||
this.audio.load();
|
this.audio.load();
|
||||||
|
|
||||||
this.sound = sound;
|
this.sound = sound;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<a class="list_item sound" onclick="player.playlist.add(new Sound(
|
<a class="list_item sound" onclick="player.playlist.add(new Sound(
|
||||||
title='{{ item.name|escape }}',
|
title='{{ item.name|escape }}',
|
||||||
detail='{{ item.detail_url }}',
|
detail='{{ item.detail_url }}',
|
||||||
stream='{% static item.path %}'));">
|
stream='{{ item.url }}'));">
|
||||||
<h3>{{ item.name }}</h3>
|
<h3>{{ item.name }}</h3>
|
||||||
<span class="info">
|
<span class="info">
|
||||||
{{ duration.date|date:'H:i:s' }}
|
{{ duration.date|date:'H:i:s' }}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user