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

Commit

Permalink
Bug 1069623 - merge pull request #28429 from eeejay:bug-1069623 to mo…
Browse files Browse the repository at this point in the history
…zilla-b2g:master
  • Loading branch information
mozilla-autolander-deprecated committed Mar 20, 2015
2 parents 7a6e62d + 3217bf6 commit 6fb68c6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/music/index.html
Expand Up @@ -117,7 +117,7 @@ <h1 id="title-text" data-l10n-id="music"></h1>
<p data-l10n-id="music-paused-notification"></p>
</section>
</div>
<div id="player-seek">
<div id="player-seek" role="slider" aria-valuemin="0">
<span id="player-seek-elapsed" dir="ltr">00:00</span>
<div id="player-seek-bar">
<progress id="player-seek-bar-progress" value="0"></progress>
Expand Down
31 changes: 30 additions & 1 deletion apps/music/js/ui/views/player_view.js
Expand Up @@ -85,6 +85,7 @@ var PlayerView = {

this.ratings = document.getElementById('player-album-rating').children;

this.seekSlider = document.getElementById('player-seek');
this.seekRegion = document.getElementById('player-seek-bar');
this.seekBar = document.getElementById('player-seek-bar-progress');
this.seekIndicator = document.getElementById('player-seek-bar-indicator');
Expand Down Expand Up @@ -116,6 +117,7 @@ var PlayerView = {
this.seekRegion.addEventListener('touchstart', this);
this.seekRegion.addEventListener('touchmove', this);
this.seekRegion.addEventListener('touchend', this);
this.seekSlider.addEventListener('keypress', this);
this.previousControl.addEventListener('touchend', this);
this.nextControl.addEventListener('touchend', this);

Expand Down Expand Up @@ -776,10 +778,22 @@ var PlayerView = {
},

setSeekBar: function pv_setSeekBar(startTime, endTime, currentTime) {
if (this.seekBar.max != endTime) {
// Duration changed, update accessibility label.
navigator.mozL10n.setAttributes(this.seekSlider,
'playbackSeekBar', {'duration': formatTime(endTime)});
}

this.seekBar.min = startTime;
this.seekBar.max = endTime;
this.seekBar.value = currentTime;

var formattedCurrentTime = formatTime(currentTime);
// Adjust values for accessibility
this.seekSlider.setAttribute('aria-valuetext', formattedCurrentTime);
this.seekSlider.setAttribute('aria-valuemax', endTime);
this.seekSlider.setAttribute('aria-valuenow', currentTime);

// if endTime is 0, that's a reset of seekBar
var ratio = (endTime !== 0) ? (currentTime / endTime) : 0;
// The width of the seek indicator must be also considered
Expand All @@ -799,7 +813,7 @@ var PlayerView = {

this.seekIndicator.style.transform = 'translateX(' + x + ')';

this.seekElapsed.textContent = formatTime(currentTime);
this.seekElapsed.textContent = formattedCurrentTime;
var remainingTime = endTime - currentTime;
// Check if there is remaining time to show, avoiding to display "-00:00"
// while song is loading (Bug 833710)
Expand Down Expand Up @@ -1042,6 +1056,21 @@ var PlayerView = {
this.next();
}
break;
case 'keypress':
// The standard accessible control for sliders is arrow up/down keys.
// Our screenreader synthesizes those events on swipe up/down gestures.
// Currently, we only allow screen reader users to adjust sliders with a
// constant step size (there is no page up/down equivalent). In the case
// of music, we make sure that the maximum amount of steps for the
// entire duration is 20, or 2 second increments if the duration is less
// then 40 seconds.
var step = Math.max(this.audio.duration / 20, 2);
if (evt.keyCode == evt.DOM_VK_DOWN) {
this.seekAudio(this.audio.currentTime - step);
} else if (evt.keyCode == evt.DOM_VK_UP) {
this.seekAudio(this.audio.currentTime + step);
}
break;
case 'contextmenu':
if (target.id === 'player-controls-next') {
this.startFastSeeking(1);
Expand Down
2 changes: 1 addition & 1 deletion apps/music/open.html
Expand Up @@ -64,7 +64,7 @@ <h1 id="title-text"></h1>
<button id="player-album-shuffle" class="player-cover-button shuffle-on" data-icon="shuffle" disabled></button>
</div>
</div>
<div id="player-seek">
<div id="player-seek" role="slider" aria-valuemin="0">
<span id="player-seek-elapsed">00:00</span>
<div id="player-seek-bar">
<progress id="player-seek-bar-progress" value="0"></progress>
Expand Down

0 comments on commit 6fb68c6

Please sign in to comment.