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

Commit

Permalink
Merge pull request #32183 from justindarc/bug996410
Browse files Browse the repository at this point in the history
Bug 996410 - [Music] Use fastSeek API in Gaia Music app
  • Loading branch information
justindarc committed Oct 2, 2015
2 parents 258d6da + 6ebc38c commit 1f96630
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 8 additions & 2 deletions apps/music/elements/music-seek-bar.js
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
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

0 comments on commit 1f96630

Please sign in to comment.