| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <include src="cache_entry.js"/> | 5 <include src="cache_entry.js"/> |
| 6 <include src="disjoint_range_set.js"/> | 6 <include src="disjoint_range_set.js"/> |
| 7 <include src="event_list.js"/> | 7 <include src="event_list.js"/> |
| 8 <include src="item_store.js"/> | 8 <include src="item_store.js"/> |
| 9 <include src="media_player.js"/> | 9 <include src="media_player.js"/> |
| 10 <include src="metrics.js"/> | 10 <include src="metrics.js"/> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 var audioStreamDiv; | 34 var audioStreamDiv; |
| 35 var cacheDiv; | 35 var cacheDiv; |
| 36 | 36 |
| 37 // A timer used to limit the rate of redrawing the Media Players section. | 37 // A timer used to limit the rate of redrawing the Media Players section. |
| 38 var redrawTimer = null; | 38 var redrawTimer = null; |
| 39 | 39 |
| 40 /** | 40 /** |
| 41 * Initialize variables and ask MediaInternals for all its data. | 41 * Initialize variables and ask MediaInternals for all its data. |
| 42 */ | 42 */ |
| 43 function initialize() { | 43 function initialize() { |
| 44 audioStreamDiv = document.getElementById('audio-streams'); | 44 audioStreamDiv = $('audio-streams'); |
| 45 cacheDiv = document.getElementById('cache-entries'); | 45 cacheDiv = $('cache-entries'); |
| 46 | 46 |
| 47 // Get information about all currently active media. | 47 // Get information about all currently active media. |
| 48 chrome.send('getEverything'); | 48 chrome.send('getEverything'); |
| 49 } | 49 } |
| 50 | 50 |
| 51 /** | 51 /** |
| 52 * Write the set of audio streams to the DOM. | 52 * Write the set of audio streams to the DOM. |
| 53 */ | 53 */ |
| 54 function printAudioStreams() { | 54 function printAudioStreams() { |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * Render a single stream as a <li>. | 57 * Render a single stream as a <li>. |
| 58 * @param {Object} stream The stream to render. | 58 * @param {Object} stream The stream to render. |
| 59 * @return {HTMLElement} A <li> containing the stream information. | 59 * @return {HTMLElement} A <li> containing the stream information. |
| 60 */ | 60 */ |
| 61 function printStream(stream) { | 61 function printStream(stream) { |
| 62 var out = document.createElement('li'); | 62 var out = document.createElement('li'); |
| 63 out.id = stream.id; | 63 out.id = stream.id; |
| 64 out.className = 'audio-stream'; | 64 out.className = 'audio-stream'; |
| 65 out.setAttribute('status', stream.status); | 65 out.setAttribute('status', stream.status); |
| 66 | 66 |
| 67 out.textContent += 'Audio stream ' + stream.id.split('.')[1]; | 67 out.textContent += 'Audio stream ' + stream.id.split('.')[1]; |
| 68 out.textContent += ' is ' + (stream.playing ? 'playing' : 'paused'); | 68 out.textContent += ' is ' + (stream.playing ? 'playing' : 'paused'); |
| 69 out.textContent += ' at ' + (stream.volume * 100).toFixed(0); | 69 if (typeof stream.volume != 'undefined') { |
| 70 out.textContent += '% volume.'; | 70 out.textContent += ' at ' + (stream.volume * 100).toFixed(0); |
| 71 out.textContent += '% volume.'; |
| 72 } |
| 71 return out; | 73 return out; |
| 72 } | 74 } |
| 73 | 75 |
| 74 var out = document.createElement('ul'); | 76 var out = document.createElement('ul'); |
| 75 audioStreams.map(printStream).forEach(function(s) { | 77 audioStreams.map(printStream).forEach(function(s) { |
| 76 out.appendChild(s) | 78 out.appendChild(s); |
| 77 }); | 79 }); |
| 78 | 80 |
| 79 audioStreamDiv.textContent = ''; | 81 audioStreamDiv.textContent = ''; |
| 80 audioStreamDiv.appendChild(out); | 82 audioStreamDiv.appendChild(out); |
| 81 } | 83 } |
| 82 | 84 |
| 83 /** | 85 /** |
| 84 * Redraw each MediaPlayer. | 86 * Redraw each MediaPlayer. |
| 85 */ | 87 */ |
| 86 function printMediaPlayers() { | 88 function printMediaPlayers() { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 142 } |
| 141 } | 143 } |
| 142 | 144 |
| 143 /** | 145 /** |
| 144 * A render process has ended, delete any media players associated with it. | 146 * A render process has ended, delete any media players associated with it. |
| 145 * @param {number} renderer The id of the render process. | 147 * @param {number} renderer The id of the render process. |
| 146 */ | 148 */ |
| 147 function onRendererTerminated(renderer) { | 149 function onRendererTerminated(renderer) { |
| 148 for (var key in mediaPlayers) { | 150 for (var key in mediaPlayers) { |
| 149 if (mediaPlayers[key].renderer == renderer) { | 151 if (mediaPlayers[key].renderer == renderer) { |
| 150 document.getElementById('media-players').removeChild(mediaPlayers[key]); | 152 $('media-players').removeChild(mediaPlayers[key]); |
| 151 delete mediaPlayers[key]; | 153 delete mediaPlayers[key]; |
| 152 break; | 154 break; |
| 153 } | 155 } |
| 154 } | 156 } |
| 155 printMediaPlayers(); | 157 printMediaPlayers(); |
| 156 } | 158 } |
| 157 | 159 |
| 158 /** | 160 /** |
| 159 * Receiving net events. | 161 * Receiving net events. |
| 160 * Update cache information and update that section of the page. | 162 * Update cache information and update that section of the page. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 onMediaEvent: onMediaEvent | 272 onMediaEvent: onMediaEvent |
| 271 }; | 273 }; |
| 272 }); | 274 }); |
| 273 | 275 |
| 274 /** | 276 /** |
| 275 * Initialize everything once we have access to the DOM. | 277 * Initialize everything once we have access to the DOM. |
| 276 */ | 278 */ |
| 277 document.addEventListener('DOMContentLoaded', function() { | 279 document.addEventListener('DOMContentLoaded', function() { |
| 278 media.initialize(); | 280 media.initialize(); |
| 279 }); | 281 }); |
| OLD | NEW |