OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
6 * Overrided metadata worker's path. | 6 * Overrided metadata worker's path. |
7 * @type {string} | 7 * @type {string} |
8 */ | 8 */ |
9 ContentMetadataProvider.WORKER_SCRIPT = '/js/metadata_worker.js'; | 9 ContentMetadataProvider.WORKER_SCRIPT = '/js/metadata_worker.js'; |
10 | 10 |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 } | 343 } |
344 }; | 344 }; |
345 | 345 |
346 /* Keep the below constants in sync with the CSS. */ | 346 /* Keep the below constants in sync with the CSS. */ |
347 | 347 |
348 /** | 348 /** |
349 * Window header size in pixels. | 349 * Window header size in pixels. |
350 * @type {number} | 350 * @type {number} |
351 * @const | 351 * @const |
352 */ | 352 */ |
353 AudioPlayer.HEADER_HEIGHT = 36; // 32px + border 4px | 353 AudioPlayer.HEADER_HEIGHT = 33; // 32px + border 1px |
| 354 |
| 355 /** |
| 356 * Top padding height of audio player in pixels. |
| 357 * @type {number} |
| 358 * @const |
| 359 */ |
| 360 AudioPlayer.TOP_PADDING_HEIGHT = 4; |
354 | 361 |
355 /** | 362 /** |
356 * Track height in pixels. | 363 * Track height in pixels. |
357 * @type {number} | 364 * @type {number} |
358 * @const | 365 * @const |
359 */ | 366 */ |
360 AudioPlayer.TRACK_HEIGHT = 48; | 367 AudioPlayer.TRACK_HEIGHT = 48; |
361 | 368 |
362 /** | 369 /** |
363 * Controls bar height in pixels. | 370 * Controls bar height in pixels. |
364 * @type {number} | 371 * @type {number} |
365 * @const | 372 * @const |
366 */ | 373 */ |
367 AudioPlayer.CONTROLS_HEIGHT = 96; | 374 AudioPlayer.CONTROLS_HEIGHT = 96; |
368 | 375 |
369 /** | 376 /** |
370 * Default number of items in the expanded mode. | 377 * Default number of items in the expanded mode. |
371 * @type {number} | 378 * @type {number} |
372 * @const | 379 * @const |
373 */ | 380 */ |
374 AudioPlayer.DEFAULT_EXPANDED_ITEMS = 5; | 381 AudioPlayer.DEFAULT_EXPANDED_ITEMS = 5; |
375 | 382 |
376 /** | 383 /** |
377 * Minimum size of the window in the expanded mode in pixels. | 384 * Minimum size of the window in the expanded mode in pixels. |
378 * @type {number} | 385 * @type {number} |
379 * @const | 386 * @const |
380 */ | 387 */ |
381 AudioPlayer.EXPANDED_MODE_MIN_HEIGHT = AudioPlayer.CONTROLS_HEIGHT + | 388 AudioPlayer.EXPANDED_MODE_MIN_HEIGHT = AudioPlayer.TOP_PADDING_HEIGHT + |
382 AudioPlayer.TRACK_HEIGHT * 2; | 389 AudioPlayer.TRACK_HEIGHT * 2 + |
| 390 AudioPlayer.CONTROLS_HEIGHT; |
383 | 391 |
384 /** | 392 /** |
385 * Invoked when the 'expanded' property in the model is changed. | 393 * Invoked when the 'expanded' property in the model is changed. |
386 * @param {boolean} newValue New value. | 394 * @param {boolean} newValue New value. |
387 * @private | 395 * @private |
388 */ | 396 */ |
389 AudioPlayer.prototype.onExpandedChanged_ = function(newValue) { | 397 AudioPlayer.prototype.onExpandedChanged_ = function(newValue) { |
390 if (this.isExpanded_ !== null && | 398 if (this.isExpanded_ !== null && |
391 this.isExpanded_ === newValue) | 399 this.isExpanded_ === newValue) |
392 return; | 400 return; |
393 | 401 |
394 if (this.isExpanded_ && !newValue) | 402 if (this.isExpanded_ && !newValue) |
395 this.lastExpandedHeight_ = window.innerHeight; | 403 this.lastExpandedInnerHeight_ = window.innerHeight; |
396 | 404 |
397 if (this.isExpanded_ !== newValue) { | 405 if (this.isExpanded_ !== newValue) { |
398 this.isExpanded_ = newValue; | 406 this.isExpanded_ = newValue; |
399 this.syncHeight_(); | 407 this.syncHeight_(); |
400 | 408 |
401 // Saves new state. | 409 // Saves new state. |
402 window.appState.expanded = newValue; | 410 window.appState.expanded = newValue; |
403 util.saveAppState(); | 411 util.saveAppState(); |
404 } | 412 } |
405 }; | 413 }; |
406 | 414 |
407 /** | 415 /** |
408 * @private | 416 * @private |
409 */ | 417 */ |
410 AudioPlayer.prototype.syncHeight_ = function() { | 418 AudioPlayer.prototype.syncHeight_ = function() { |
411 var targetHeight; | 419 var targetInnerHeight; |
412 | 420 |
413 if (this.player_.expanded) { | 421 if (this.player_.expanded) { |
414 // Expanded. | 422 // Expanded. |
415 if (!this.lastExpandedHeight_ || | 423 if (!this.lastExpandedInnerHeight_ || |
416 this.lastExpandedHeight_ < AudioPlayer.EXPANDED_MODE_MIN_HEIGHT) { | 424 this.lastExpandedInnerHeight_ < AudioPlayer.EXPANDED_MODE_MIN_HEIGHT) { |
417 var expandedListHeight = | 425 var expandedListHeight = |
418 Math.min(this.entries_.length, AudioPlayer.DEFAULT_EXPANDED_ITEMS) * | 426 Math.min(this.entries_.length, AudioPlayer.DEFAULT_EXPANDED_ITEMS) * |
419 AudioPlayer.TRACK_HEIGHT; | 427 AudioPlayer.TRACK_HEIGHT; |
420 targetHeight = AudioPlayer.CONTROLS_HEIGHT + expandedListHeight; | 428 targetInnerHeight = AudioPlayer.TOP_PADDING_HEIGHT + |
421 this.lastExpandedHeight_ = targetHeight; | 429 expandedListHeight + |
| 430 AudioPlayer.CONTROLS_HEIGHT; |
| 431 this.lastExpandedInnerHeight_ = targetInnerHeight; |
422 } else { | 432 } else { |
423 targetHeight = this.lastExpandedHeight_; | 433 targetInnerHeight = this.lastExpandedInnerHeight_; |
424 } | 434 } |
425 } else { | 435 } else { |
426 // Not expanded. | 436 // Not expanded. |
427 targetHeight = AudioPlayer.CONTROLS_HEIGHT + AudioPlayer.TRACK_HEIGHT; | 437 targetInnerHeight = AudioPlayer.TOP_PADDING_HEIGHT + |
| 438 AudioPlayer.TRACK_HEIGHT + |
| 439 AudioPlayer.CONTROLS_HEIGHT; |
428 } | 440 } |
429 | 441 window.resizeTo(window.outerWidth, |
430 window.resizeTo(window.innerWidth, targetHeight + AudioPlayer.HEADER_HEIGHT); | 442 AudioPlayer.HEADER_HEIGHT + targetInnerHeight); |
431 }; | 443 }; |
432 | 444 |
433 /** | 445 /** |
434 * Create a TrackInfo object encapsulating the information about one track. | 446 * Create a TrackInfo object encapsulating the information about one track. |
435 * | 447 * |
436 * @param {FileEntry} entry FileEntry to be retrieved the track info from. | 448 * @param {FileEntry} entry FileEntry to be retrieved the track info from. |
437 * @constructor | 449 * @constructor |
438 */ | 450 */ |
439 AudioPlayer.TrackInfo = function(entry) { | 451 AudioPlayer.TrackInfo = function(entry) { |
440 this.url = entry.toURL(); | 452 this.url = entry.toURL(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 // TODO(yoshiki): Handle error in better way. | 490 // TODO(yoshiki): Handle error in better way. |
479 // TODO(yoshiki): implement artwork (metadata.thumbnail) | 491 // TODO(yoshiki): implement artwork (metadata.thumbnail) |
480 this.title = metadata.mediaTitle || this.getDefaultTitle(); | 492 this.title = metadata.mediaTitle || this.getDefaultTitle(); |
481 this.artist = error || metadata.mediaArtist || this.getDefaultArtist(); | 493 this.artist = error || metadata.mediaArtist || this.getDefaultArtist(); |
482 }; | 494 }; |
483 | 495 |
484 // Starts loading the audio player. | 496 // Starts loading the audio player. |
485 window.addEventListener('DOMContentLoaded', function(e) { | 497 window.addEventListener('DOMContentLoaded', function(e) { |
486 AudioPlayer.load(); | 498 AudioPlayer.load(); |
487 }); | 499 }); |
OLD | NEW |