From c7e59c1f5a0a77be96fe548242486dcc817e055d Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 24 Jul 2014 11:28:01 +0200 Subject: [PATCH] audio player: handle audio option update; cosmetic changes --- source/Ox.UI/js/Audio/AudioPlayer.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/source/Ox.UI/js/Audio/AudioPlayer.js b/source/Ox.UI/js/Audio/AudioPlayer.js index 54ef7abf..9d0a494c 100644 --- a/source/Ox.UI/js/Audio/AudioPlayer.js +++ b/source/Ox.UI/js/Audio/AudioPlayer.js @@ -22,6 +22,15 @@ Ox.AudioPlayer = function(options, self) { }) .options(options || {}) .update({ + audio: function() { + self.options.position = -1; + self.options.track = -1; + that.options({ + paused: true, + position: 0, + track: 0 + }); + }, muted: function() { self.options.muted = !self.options.muted; toggleMuted(); @@ -250,14 +259,14 @@ Ox.AudioPlayer = function(options, self) { function playing() { self.options.position = self.$audio.currentTime(); - setPosition(self.options.position, 'video') + setPosition(self.options.position, 'audio') that.triggerEvent('playing', {position: self.options.position}); } function playNext() { var track = getNextTrack(); if (track === null) { - + // ... } else { setTrack(track); } @@ -265,7 +274,7 @@ Ox.AudioPlayer = function(options, self) { function setPosition(position, from) { self.options.position = position; - if (from != 'video') { + if (from != 'audio') { self.$audio.currentTime(position); } self.$positionSlider.options({ @@ -303,8 +312,8 @@ Ox.AudioPlayer = function(options, self) { self.options.track = track; self.$trackLabel.options({ title: [ - data.title, data.artist, data.album, data.year - ].join(' — ') + data.name, data.artist, data.album, data.year + ].join(' · ') }); self.$audio.options({src: self.options.audio[self.options.track].file}); !self.options.paused && self.$audio.play();