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 document.addEventListener('DOMContentLoaded', function() { | 5 document.addEventListener('DOMContentLoaded', function() { |
6 // Test harness sets the search string to prevent the automatic load. | 6 // Test harness sets the search string to prevent the automatic load. |
7 // It calls AudioPlayer.load() explicitly after initializing | 7 // It calls AudioPlayer.load() explicitly after initializing |
8 // the |chrome| variable with an appropriate mock object. | 8 // the |chrome| variable with an appropriate mock object. |
9 if (!document.location.search) { | 9 if (!document.location.search) { |
10 AudioPlayer.load(); | 10 AudioPlayer.load(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 'click', this.onExpandCollapse_.bind(this)); | 44 'click', this.onExpandCollapse_.bind(this)); |
45 | 45 |
46 this.audioControls_ = new AudioControls( | 46 this.audioControls_ = new AudioControls( |
47 createChild(), this.advance_.bind(this)); | 47 createChild(), this.advance_.bind(this)); |
48 | 48 |
49 this.audioControls_.attachMedia(createChild('', 'audio')); | 49 this.audioControls_.attachMedia(createChild('', 'audio')); |
50 } | 50 } |
51 | 51 |
52 AudioPlayer.load = function() { | 52 AudioPlayer.load = function() { |
53 document.ondragstart = function(e) { e.preventDefault() }; | 53 document.ondragstart = function(e) { e.preventDefault() }; |
| 54 document.oncontextmenu = function(e) { e.preventDefault(); }; |
54 | 55 |
55 var player = new AudioPlayer(document.querySelector('.audio-player')); | 56 var player = new AudioPlayer(document.querySelector('.audio-player')); |
56 function getPlaylist() { | 57 function getPlaylist() { |
57 chrome.mediaPlayerPrivate.getPlaylist(player.load.bind(player)); | 58 chrome.mediaPlayerPrivate.getPlaylist(player.load.bind(player)); |
58 } | 59 } |
59 getPlaylist(); | 60 getPlaylist(); |
60 chrome.mediaPlayerPrivate.onPlaylistChanged.addListener(getPlaylist); | 61 chrome.mediaPlayerPrivate.onPlaylistChanged.addListener(getPlaylist); |
61 }; | 62 }; |
62 | 63 |
63 AudioPlayer.prototype.load = function(playlist) { | 64 AudioPlayer.prototype.load = function(playlist) { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 }; | 264 }; |
264 | 265 |
265 AudioPlayer.TrackInfo.prototype.setMetadata = function(metadata) { | 266 AudioPlayer.TrackInfo.prototype.setMetadata = function(metadata) { |
266 if (metadata.thumbnailURL) { | 267 if (metadata.thumbnailURL) { |
267 this.art_.classList.remove('blank'); | 268 this.art_.classList.remove('blank'); |
268 this.img_.src = metadata.thumbnailURL; | 269 this.img_.src = metadata.thumbnailURL; |
269 } | 270 } |
270 this.title_.textContent = metadata.title || this.getDefaultTitle(); | 271 this.title_.textContent = metadata.title || this.getDefaultTitle(); |
271 this.artist_.textContent = metadata.artist || this.getDefaultArtist(); | 272 this.artist_.textContent = metadata.artist || this.getDefaultArtist(); |
272 }; | 273 }; |
OLD | NEW |