Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Bug 996410 - [Music] Use fastSeek API in Gaia Music app #32183

Merged
merged 1 commit into from
Oct 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions apps/music/elements/music-seek-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ var template =
width: 2.3rem;
height: 2.3rem;
pointer-events: none;
will-change: transform;
}
#seek-bar-indicator:after {
content: '';
Expand All @@ -79,6 +80,9 @@ var template =
width: 2.1rem;
height: 2.1rem;
}
#seek-bar-indicator.highlight {
transition: transform 50ms linear;
}
#seek-bar-indicator.highlight:before {
content: '';
background-color: #00caf2;
Expand Down Expand Up @@ -121,7 +125,7 @@ proto.createdCallback = function() {
this.dispatchEvent(new CustomEvent('seek', {
detail: { elapsedTime: this.elapsedTime }
}));
}, 100);
}, 250);

container.addEventListener(isTouch ? 'touchstart' : 'mousedown', (evt) => {
container.addEventListener(isTouch ? 'touchmove' : 'mousemove',
Expand Down Expand Up @@ -245,7 +249,9 @@ Object.defineProperty(proto, 'remainingTime', {
x = this.els.seekBar.offsetWidth - x;
}

this.els.seekBarIndicator.style.transform = 'translateX(' + x + 'px)';
window.requestAnimationFrame(() => {
this.els.seekBarIndicator.style.transform = 'translateX(' + x + 'px)';
});
}
});

Expand Down
5 changes: 3 additions & 2 deletions apps/music/js/endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ function stop() {
}

function seek(time) {
time = parseInt(time, 10);
audio.currentTime = time;
audio.fastSeek(parseInt(time, 10));
}

function startFastSeek(reverse) {
Expand All @@ -160,9 +159,11 @@ function startFastSeek(reverse) {

function fastSeek() {
if (!isFastSeeking) {
audio.volume = 1;
return;
}

audio.volume = 0.5;
seek(audio.currentTime + (reverse ? -2 : 2));
setTimeout(fastSeek, 50);
}
Expand Down