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

Unified Diff: ui/file_manager/audio_player/elements/audio_player.js

Issue 1458733003: Reland MD Audio Player. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: forcePlay -> forceToPlay 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 side-by-side diff with in-line comments
Download patch
Index: ui/file_manager/audio_player/elements/audio_player.js
diff --git a/ui/file_manager/audio_player/elements/audio_player.js b/ui/file_manager/audio_player/elements/audio_player.js
index 3d5fc01410f187a30115251c438f044aed636760..6c1820f4ee9cbd9ae441741b481e3f9f4eaf2867 100644
--- a/ui/file_manager/audio_player/elements/audio_player.js
+++ b/ui/file_manager/audio_player/elements/audio_player.js
@@ -90,10 +90,20 @@ Polymer({
type: Number,
value: 0,
reflectToAttribute: true
+ },
+
+ ariaLabels: {
+ type: Object
}
},
/**
+ * The last playing state when user starts dragging the seek bar.
+ * @private {boolean}
+ */
+ wasPlayingOnDragStart_: false,
+
+ /**
* Handles change event for shuffle mode.
* @param {boolean} shuffle
*/
@@ -135,6 +145,9 @@ Polymer({
ready: function() {
this.addEventListener('keydown', this.onKeyDown_.bind(this));
+ this.$.audioController.addEventListener('dragging-changed',
+ this.onDraggingChanged_.bind(this));
+
this.$.audio.volume = 0; // Temporary initial volume.
this.$.audio.addEventListener('ended', this.onAudioEnded.bind(this));
this.$.audio.addEventListener('error', this.onAudioError.bind(this));
@@ -275,6 +288,13 @@ Polymer({
},
/**
+ * Invoked when receivig a request to start playing the current music.
+ */
+ onPlayCurrentTrack: function() {
+ this.$.audio.play();
+ },
+
+ /**
* Invoked when receiving a request to replay the current music from the track
* list element.
*/
@@ -396,6 +416,24 @@ Polymer({
},
/**
+ * Invoked when dragging state of seek bar on control panel is changed.
+ * During the user is dragging it, audio playback is paused temporalily.
+ */
+ onDraggingChanged_: function() {
+ if (this.$.audioController.dragging) {
+ if (this.playing) {
+ this.wasPlayingOnDragStart_ = true;
+ this.$.audio.pause();
+ }
+ } else {
+ if (this.wasPlayingOnDragStart_) {
+ this.$.audio.play();
+ this.wasPlayingOnDragStart_ = false;
+ }
+ }
+ },
+
+ /**
* Invoked when the 'keydown' event is fired.
* @param {Event} event The event object.
*/
« no previous file with comments | « ui/file_manager/audio_player/elements/audio_player.html ('k') | ui/file_manager/audio_player/elements/compiled_resources.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698