audio player: handle audio option update; cosmetic changes
This commit is contained in:
parent
a4849859d6
commit
c7e59c1f5a
1 changed files with 14 additions and 5 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue