Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: ui/file_manager/audio_player/elements/audio_player.js

Issue 1403303011: AudioPlayer: Update control panel with playback progress bar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 Polymer({ 5 Polymer({
6 is: 'audio-player', 6 is: 'audio-player',
7 7
8 properties: { 8 properties: {
9 /** 9 /**
10 * Flag whether the audio is playing or paused. True if playing, or false 10 * Flag whether the audio is playing or paused. True if playing, or false
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 * The number of played tracks. (exposed publicly for tests) 87 * The number of played tracks. (exposed publicly for tests)
88 */ 88 */
89 playcount: { 89 playcount: {
90 type: Number, 90 type: Number,
91 value: 0, 91 value: 0,
92 reflectToAttribute: true 92 reflectToAttribute: true
93 } 93 }
94 }, 94 },
95 95
96 /** 96 /**
97 * The last playing state when user starts dragging the seek bar.
98 * @private {boolean}
99 */
100 wasPlayingOnDragStart_: false,
101
102 /**
97 * Handles change event for shuffle mode. 103 * Handles change event for shuffle mode.
98 * @param {boolean} shuffle 104 * @param {boolean} shuffle
99 */ 105 */
100 shuffleChanged: function(shuffle) { 106 shuffleChanged: function(shuffle) {
101 if (this.model) 107 if (this.model)
102 this.model.shuffle = shuffle; 108 this.model.shuffle = shuffle;
103 }, 109 },
104 110
105 /** 111 /**
106 * Handles change event for repeat mode. 112 * Handles change event for repeat mode.
(...skipping 21 matching lines...) Expand all
128 this.model.expanded = expanded; 134 this.model.expanded = expanded;
129 }, 135 },
130 136
131 /** 137 /**
132 * Initializes an element. This method is called automatically when the 138 * Initializes an element. This method is called automatically when the
133 * element is ready. 139 * element is ready.
134 */ 140 */
135 ready: function() { 141 ready: function() {
136 this.addEventListener('keydown', this.onKeyDown_.bind(this)); 142 this.addEventListener('keydown', this.onKeyDown_.bind(this));
137 143
144 this.$.audioController.addEventListener('dragging-changed',
145 this.onDraggingChanged_.bind(this));
146
138 this.$.audio.volume = 0; // Temporary initial volume. 147 this.$.audio.volume = 0; // Temporary initial volume.
139 this.$.audio.addEventListener('ended', this.onAudioEnded.bind(this)); 148 this.$.audio.addEventListener('ended', this.onAudioEnded.bind(this));
140 this.$.audio.addEventListener('error', this.onAudioError.bind(this)); 149 this.$.audio.addEventListener('error', this.onAudioError.bind(this));
141 150
142 var onAudioStatusUpdatedBound = this.onAudioStatusUpdate_.bind(this); 151 var onAudioStatusUpdatedBound = this.onAudioStatusUpdate_.bind(this);
143 this.$.audio.addEventListener('timeupdate', onAudioStatusUpdatedBound); 152 this.$.audio.addEventListener('timeupdate', onAudioStatusUpdatedBound);
144 this.$.audio.addEventListener('ended', onAudioStatusUpdatedBound); 153 this.$.audio.addEventListener('ended', onAudioStatusUpdatedBound);
145 this.$.audio.addEventListener('play', onAudioStatusUpdatedBound); 154 this.$.audio.addEventListener('play', onAudioStatusUpdatedBound);
146 this.$.audio.addEventListener('pause', onAudioStatusUpdatedBound); 155 this.$.audio.addEventListener('pause', onAudioStatusUpdatedBound);
147 this.$.audio.addEventListener('suspend', onAudioStatusUpdatedBound); 156 this.$.audio.addEventListener('suspend', onAudioStatusUpdatedBound);
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 }, 398 },
390 399
391 /** 400 /**
392 * Invoked when the audio player is being unloaded. 401 * Invoked when the audio player is being unloaded.
393 */ 402 */
394 onPageUnload: function() { 403 onPageUnload: function() {
395 this.$.audio.src = ''; // Hack to prevent crashing. 404 this.$.audio.src = ''; // Hack to prevent crashing.
396 }, 405 },
397 406
398 /** 407 /**
408 * Invoked then dragging state of seek bar on control panel is changed.
yawano 2015/10/30 01:59:53 typo: then -> when
fukino 2015/10/30 04:25:53 Done.
409 * During the user is dragging it, audio playback is paused temporalily.
410 */
411 onDraggingChanged_: function() {
412 if (this.$.audioController.dragging) {
413 if (this.playing) {
414 this.wasPlayingOnDragStart_ = true;
415 this.$.audio.pause();
416 }
417 } else {
418 if (this.wasPlayingOnDragStart_) {
419 this.$.audio.play();
420 this.wasPlayingOnDragStart_ = false;
421 }
422 }
423 },
424
425 /**
399 * Invoked when the 'keydown' event is fired. 426 * Invoked when the 'keydown' event is fired.
400 * @param {Event} event The event object. 427 * @param {Event} event The event object.
401 */ 428 */
402 onKeyDown_: function(event) { 429 onKeyDown_: function(event) {
403 switch (event.keyIdentifier) { 430 switch (event.keyIdentifier) {
404 case 'Up': 431 case 'Up':
405 if (this.$.audioController.volumeSliderShown && this.model.volume < 100) 432 if (this.$.audioController.volumeSliderShown && this.model.volume < 100)
406 this.model.volume += 1; 433 this.model.volume += 1;
407 break; 434 break;
408 case 'Down': 435 case 'Down':
(...skipping 25 matching lines...) Expand all
434 461
435 /** 462 /**
436 * Computes volume value for audio element. (should be in [0.0, 1.0]) 463 * Computes volume value for audio element. (should be in [0.0, 1.0])
437 * @param {number} volume Volume which is set in the UI. ([0, 100]) 464 * @param {number} volume Volume which is set in the UI. ([0, 100])
438 * @return {number} 465 * @return {number}
439 */ 466 */
440 computeAudioVolume_: function(volume) { 467 computeAudioVolume_: function(volume) {
441 return volume / 100; 468 return volume / 100;
442 } 469 }
443 }); 470 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698