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

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

Issue 1431523003: AudioPlayer: Start playing a track when play icon on the track list is clicked. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months 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
« no previous file with comments | « ui/file_manager/audio_player/elements/audio_player.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/audio_player/elements/track_list.js
diff --git a/ui/file_manager/audio_player/elements/track_list.js b/ui/file_manager/audio_player/elements/track_list.js
index 95894edfd8bc4f3fa654395f33a088949537b641..6bc10747d6cd710bb9828afeff695604ce25ef94 100644
--- a/ui/file_manager/audio_player/elements/track_list.js
+++ b/ui/file_manager/audio_player/elements/track_list.js
@@ -166,8 +166,15 @@ var TrackInfo;
trackClicked: function(event) {
var index = ~~event.currentTarget.getAttribute('index');
var track = this.tracks[index];
- if (track)
- this.selectTrack(track);
+ if (track) {
+ if (event.target.classList.contains('icon')) {
yawano 2015/10/30 09:02:00 This will catch tap event of non-active and non-ho
fukino 2015/10/30 09:28:14 Good catch! I set pointer-events: none by default.
+ // If the play icon on the track is clicked, change the current track
+ // and start playing it regardless of current play state.
+ this.selectTrack(track, true);
yawano 2015/10/30 09:01:59 optional nit: add comment about second parameter.
fukino 2015/10/30 09:28:14 Done.
+ } else {
+ this.selectTrack(track, false);
+ }
+ }
},
/**
@@ -250,8 +257,10 @@ var TrackInfo;
* Sets the current track.
* @param {!TrackInfo} track TrackInfo to be set as the current
* track.
+ * @param {boolean} forcePlay True if the track should be played regardless
+ * of the current play state (paused/played).
*/
- selectTrack: function(track) {
+ selectTrack: function(track, forcePlay) {
var index = -1;
for (var i = 0; i < this.tracks.length; i++) {
if (this.tracks[i].url === track.url) {
@@ -261,10 +270,13 @@ var TrackInfo;
}
if (index >= 0) {
// TODO(yoshiki): Clean up the flow and the code around here.
- if (this.currentTrackIndex == index)
+ if (this.currentTrackIndex === index) {
this.replayCurrentTrack();
- else
+ } else {
this.currentTrackIndex = index;
+ if (forcePlay)
+ this.fire('play');
+ }
}
},
« no previous file with comments | « ui/file_manager/audio_player/elements/audio_player.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698