Commit 9a2e0a8a authored by yoshiki's avatar yoshiki Committed by Commit bot

Audio Player: Don't update the track list when the list is not changed

Previously, when user clicked the audio file on Files.app, the track list was updated unexpectedly and the current track index was set to the default (the first file) for a very short time just before the index was updated to the selected file. This unexpected change in short period made the playback time reset and caused the issue (crbug.com/395868). This patch fixes this issue.

BUG=395868
TEST=none

Review URL: https://codereview.chromium.org/515443002

Cr-Commit-Position: refs/heads/master@{#292565}
parent ba3229b2
......@@ -117,18 +117,25 @@ AudioPlayer.prototype.load = function(playlist) {
return;
var newTracks = [];
var currentTracks = this.player_.tracks;
var unchanged = (currentTracks.length === this.entries_.length);
for (var i = 0; i != this.entries_.length; i++) {
var entry = this.entries_[i];
var onClick = this.select_.bind(this, i, false /* no restore */);
var onClick = this.select_.bind(this, i);
newTracks.push(new AudioPlayer.TrackInfo(entry, onClick));
if (unchanged && entry.toURL() !== currentTracks[i].url)
unchanged = false;
}
this.player_.tracks = newTracks;
if (!unchanged) {
this.player_.tracks = newTracks;
// Makes it sure that the handler of the track list is called, before the
// handler of the track index.
Platform.performMicrotaskCheckpoint();
// Makes it sure that the handler of the track list is called, before
// the handler of the track index.
Platform.performMicrotaskCheckpoint();
}
this.select_(position, !!time);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment