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

Side by Side Diff: chrome/browser/resources/file_manager/audio_player/elements/audio_player.js

Issue 182733009: [AudioPlayer] Don't start a playback automatically when reopening (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/audio_player/js/audio_player.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 'use strict'; 5 'use strict';
6 6
7 Polymer('audio-player', { 7 Polymer('audio-player', {
8 /** 8 /**
9 * Child Elements 9 * Child Elements
10 */ 10 */
11 audioController: null, 11 audioController: null,
12 audioElement: null, 12 audioElement: null,
13 trackList: null, 13 trackList: null,
14 14
15 // Attributes of the element (little charactor only) 15 // Attributes of the element (little charactor only).
16 // These value must be used only to data binding and shouldn't be assignred
17 // anu value nowhere except in the handler.
16 playing: false, 18 playing: false,
17 currenttrackurl: '', 19 currenttrackurl: '',
18 20
19 /** 21 /**
20 * Model object of the Audio Player. 22 * Model object of the Audio Player.
21 * @type {AudioPlayerModel} 23 * @type {AudioPlayerModel}
22 */ 24 */
23 model: null, 25 model: null,
24 26
25 /** 27 /**
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 * @param {number} newValue new value. 65 * @param {number} newValue new value.
64 */ 66 */
65 onCurrentTrackIndexChanged: function(oldValue, newValue) { 67 onCurrentTrackIndexChanged: function(oldValue, newValue) {
66 var currentTrackUrl = ''; 68 var currentTrackUrl = '';
67 69
68 if (oldValue != newValue) { 70 if (oldValue != newValue) {
69 var currentTrack = this.trackList.getCurrentTrack(); 71 var currentTrack = this.trackList.getCurrentTrack();
70 if (currentTrack && currentTrack.url != this.audioElement.src) { 72 if (currentTrack && currentTrack.url != this.audioElement.src) {
71 this.audioElement.src = currentTrack.url; 73 this.audioElement.src = currentTrack.url;
72 currentTrackUrl = this.audioElement.src; 74 currentTrackUrl = this.audioElement.src;
73 this.audioElement.play(); 75 if (this.audioController.playing)
76 this.audioElement.play();
74 } 77 }
75 } 78 }
76 79
77 // The attributes may be being watched, so we change it at the last. 80 // The attributes may be being watched, so we change it at the last.
78 this.currenttrackurl = currentTrackUrl; 81 this.currenttrackurl = currentTrackUrl;
79 }, 82 },
80 83
81 /** 84 /**
82 * Invoked when audioController.playing is changed. 85 * Invoked when audioController.playing is changed.
83 * @param {boolean} oldValue old value. 86 * @param {boolean} oldValue old value.
(...skipping 12 matching lines...) Expand all
96 99
97 if (this.audioElement.src) { 100 if (this.audioElement.src) {
98 this.currenttrackurl = this.audioElement.src; 101 this.currenttrackurl = this.audioElement.src;
99 this.audioElement.play(); 102 this.audioElement.play();
100 return; 103 return;
101 } 104 }
102 } 105 }
103 106
104 // When the new status is "stopped". 107 // When the new status is "stopped".
105 this.cancelAutoAdvance_(); 108 this.cancelAutoAdvance_();
106 this.audioController.playing = false;
107 this.audioElement.pause(); 109 this.audioElement.pause();
108 this.currenttrackurl = ''; 110 this.currenttrackurl = '';
109 this.lastAudioUpdateTime_ = null; 111 this.lastAudioUpdateTime_ = null;
110 }, 112 },
111 113
112 /** 114 /**
113 * Invoked when audioController.volume is changed. 115 * Invoked when audioController.volume is changed.
114 * @param {number} oldValue old value. 116 * @param {number} oldValue old value.
115 * @param {number} newValue new value. 117 * @param {number} newValue new value.
116 */ 118 */
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 * @param {boolean} repeat True if repeat-mode is enabled. False otherwise. 197 * @param {boolean} repeat True if repeat-mode is enabled. False otherwise.
196 * @private 198 * @private
197 */ 199 */
198 advance_: function(forward, repeat) { 200 advance_: function(forward, repeat) {
199 this.cancelAutoAdvance_(); 201 this.cancelAutoAdvance_();
200 202
201 var nextTrackIndex = this.trackList.getNextTrackIndex(forward, true); 203 var nextTrackIndex = this.trackList.getNextTrackIndex(forward, true);
202 var isNextTrackAvailable = 204 var isNextTrackAvailable =
203 (this.trackList.getNextTrackIndex(forward, repeat) !== -1); 205 (this.trackList.getNextTrackIndex(forward, repeat) !== -1);
204 206
207 this.audioController.playing = isNextTrackAvailable;
205 this.trackList.currentTrackIndex = nextTrackIndex; 208 this.trackList.currentTrackIndex = nextTrackIndex;
206 209
207 if (isNextTrackAvailable) { 210 Platform.performMicrotaskCheckpoint();
208 var nextTrack = this.trackList.tracks[nextTrackIndex];
209 this.audioElement.src = nextTrack.url;
210 this.audioElement.play();
211 } else {
212 this.audioElement.pause();
213 }
214 }, 211 },
215 212
216 /** 213 /**
217 * Timeout ID of auto advance. Used internally in scheduleAutoAdvance_() and 214 * Timeout ID of auto advance. Used internally in scheduleAutoAdvance_() and
218 * cancelAutoAdvance_(). 215 * cancelAutoAdvance_().
219 * @type {number} 216 * @type {number}
220 * @private 217 * @private
221 */ 218 */
222 autoAdvanceTimer_: null, 219 autoAdvanceTimer_: null,
223 220
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 } 286 }
290 }, 287 },
291 288
292 /** 289 /**
293 * Invoked when the audio player is being unloaded. 290 * Invoked when the audio player is being unloaded.
294 */ 291 */
295 onPageUnload: function() { 292 onPageUnload: function() {
296 this.audioElement.src = ''; // Hack to prevent crashing. 293 this.audioElement.src = ''; // Hack to prevent crashing.
297 }, 294 },
298 }); 295 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/audio_player/js/audio_player.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698