diff --git a/aircox/models.py b/aircox/models.py index 51a8945..6b6b1f5 100755 --- a/aircox/models.py +++ b/aircox/models.py @@ -999,7 +999,10 @@ class Sound(Nameable): return None import mutagen - meta = mutagen.File(self.path) + try: + meta = mutagen.File(self.path) + except: + meta = {} def get_meta(key, cast=str): value = meta.get(key) diff --git a/aircox_cms/models.py b/aircox_cms/models.py index 3b6d92b..0fbbd32 100755 --- a/aircox_cms/models.py +++ b/aircox_cms/models.py @@ -550,7 +550,7 @@ class DiffusionPage(Publication): sound = self.diffusion.get_archives() \ .filter(public = True).first() if sound: - sound.detail_url = self.detail_url + sound.detail_url = self.url return sound def get_podcasts(self): @@ -682,6 +682,11 @@ class LogsPage(DatedListPage): help_text = _('maximum days in the past allowed to be shown. ' '0 means no limit') ) + reverse = models.BooleanField( + _('reverse list'), + default=False, + help_text = _('print logs in ascending order by date'), + ) class Meta: verbose_name = _('Logs') @@ -691,6 +696,7 @@ class LogsPage(DatedListPage): MultiFieldPanel([ FieldPanel('station'), FieldPanel('age_max'), + FieldPanel('reverse'), ], heading=_('Configuration')), ] @@ -718,7 +724,9 @@ class LogsPage(DatedListPage): for date in context['nav_dates']['dates']: items = [ SectionLogsList.as_item(item) for item in self.station.on_air(date = date) ] - logs.append((date, items)) + logs.append( + (date, reversed(items) if self.reverse else items) + ) return logs diff --git a/aircox_cms/static/aircox_cms/css/layout.css b/aircox_cms/static/aircox_cms/css/layout.css index a1d70bb..b393053 100755 --- a/aircox_cms/static/aircox_cms/css/layout.css +++ b/aircox_cms/static/aircox_cms/css/layout.css @@ -323,6 +323,14 @@ ul.list { display: inline; } + .player .playlist .duration { + text-align: right; + } + + .player .playlist progress { + width: 100%; + } + .player .item[selected] { border-left: 1px #007EDF solid; @@ -345,7 +353,6 @@ ul.list { max-height: 2.0em; } - .player:not([state]) .item[selected] .button > img:not(.play), .player[state="paused"] .item[selected] .button > img:not(.play), .player[state="playing"] .item[selected] .button > img:not(.pause), diff --git a/aircox_cms/static/aircox_cms/js/player.js b/aircox_cms/static/aircox_cms/js/player.js index 851d519..e5282cf 100755 --- a/aircox_cms/static/aircox_cms/js/player.js +++ b/aircox_cms/static/aircox_cms/js/player.js @@ -36,6 +36,7 @@ Sound.prototype = { on_air: false, item: undefined, + position_item: undefined, get seekable() { return this.duration != undefined; @@ -59,6 +60,7 @@ Sound.prototype = { item.sound = this; this.item = item; + this.position_item = item.querySelector('.position'); // events var self = this; @@ -164,9 +166,9 @@ Playlist.prototype = { sound.item.setAttribute('selected', 'true'); if(!sound.on_air) - sound.item.querySelector('.content').insertBefore( - this.player.progress.item, - sound.item.querySelector('.content .duration') + sound.item.querySelector('.content').parentNode.appendChild( + this.player.progress.item //, + // sound.item.querySelector('.content .duration') ) if(sound.seekable) @@ -217,6 +219,7 @@ Playlist.prototype = { }, } +var ActivePlayer = null; function Player(id, on_air_url, show_cover) { this.id = id; @@ -253,6 +256,10 @@ Player.prototype = { sound: undefined, on_air_url: undefined, + get sound() { + return this.playlist.sound; + }, + init_events: function() { var self = this; @@ -265,19 +272,20 @@ Player.prototype = { function update_info() { var progress = self.progress; var pos = self.audio.currentTime; + var position = self.sound.position_item; // progress - if(!self.sound || !self.sound.seekable || + if(!self.audio || !self.audio.seekable || !pos || self.audio.duration == Infinity) { - progress.duration.innerHTML = ''; + position.innerHTML = ''; progress.bar.value = 0; return; } progress.bar.value = pos; progress.bar.max = self.audio.duration; - progress.duration.innerHTML = duration_str(pos); + position.innerHTML = duration_str(pos); } // audio @@ -302,7 +310,7 @@ Player.prototype = { this.audio.addEventListener('ended', function() { self.player.removeAttribute('state'); if(!self.controls.single.checked) - self.next(true); + self.playlist.next(true); }, false); // progress @@ -318,7 +326,8 @@ Player.prototype = { return; var pos = time_from_progress(event); - self.progress.duration.innerHTML = duration_str(pos); + var position = self.sound.position_item; + position.innerHTML = duration_str(pos); }, false); }, @@ -368,6 +377,11 @@ Player.prototype = { }, play: function() { + if(ActivePlayer && ActivePlayer != this) { + ActivePlayer.stop(); + } + ActivePlayer = this; + if(this.audio.paused) this.audio.play(); else diff --git a/aircox_cms/templates/aircox_cms/sections/section_player.html b/aircox_cms/templates/aircox_cms/sections/section_player.html index 565c3f5..cc720dd 100755 --- a/aircox_cms/templates/aircox_cms/sections/section_player.html +++ b/aircox_cms/templates/aircox_cms/sections/section_player.html @@ -7,7 +7,7 @@