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"/> |
| 6 <include src="item_store.js"/> |
| 7 <include src="disjoint_range_set.js"/> |
| 8 |
5 cr.define('media', function() { | 9 cr.define('media', function() { |
6 | 10 |
7 // Stores information on open audio streams, referenced by id. | 11 // Stores information on open audio streams, referenced by id. |
8 var audioStreams = new media.ItemStore; | 12 var audioStreams = new media.ItemStore; |
9 | 13 |
10 // Cached files indexed by key and source id. | 14 // Cached files indexed by key and source id. |
11 var cacheEntriesByKey = {}; | 15 var cacheEntriesByKey = {}; |
12 var cacheEntries = {}; | 16 var cacheEntries = {}; |
13 | 17 |
14 // Map of event source -> url. | 18 // Map of event source -> url. |
(...skipping 26 matching lines...) Expand all Loading... |
41 * Render a single stream as a <li>. | 45 * Render a single stream as a <li>. |
42 * @param {Object} stream The stream to render. | 46 * @param {Object} stream The stream to render. |
43 * @return {HTMLElement} A <li> containing the stream information. | 47 * @return {HTMLElement} A <li> containing the stream information. |
44 */ | 48 */ |
45 printStream = function(stream) { | 49 printStream = function(stream) { |
46 var out = document.createElement('li'); | 50 var out = document.createElement('li'); |
47 out.id = stream.id; | 51 out.id = stream.id; |
48 out.className = 'audio-stream'; | 52 out.className = 'audio-stream'; |
49 out.setAttribute('status', stream.status); | 53 out.setAttribute('status', stream.status); |
50 | 54 |
51 out.innerHTML += 'Audio stream ' + stream.id.split('.')[1]; | 55 out.textContent += 'Audio stream ' + stream.id.split('.')[1]; |
52 out.innerHTML += ' is ' + (stream.playing ? 'playing' : 'paused'); | 56 out.textContent += ' is ' + (stream.playing ? 'playing' : 'paused'); |
53 out.innerHTML += ' at ' + Math.round(stream.volume * 100) + '% volume.'; | 57 out.textContent += ' at ' + Math.round(stream.volume * 100) + '% volume.'; |
54 return out; | 58 return out; |
55 }; | 59 }; |
56 | 60 |
57 var out = document.createElement('ul'); | 61 var out = document.createElement('ul'); |
58 audioStreams.map(printStream).forEach(function(s) { | 62 audioStreams.map(printStream).forEach(function(s) { |
59 out.appendChild(s) | 63 out.appendChild(s) |
60 }); | 64 }); |
61 | 65 |
62 audioStreamDiv.textContent = ''; | 66 audioStreamDiv.textContent = ''; |
63 audioStreamDiv.appendChild(out); | 67 audioStreamDiv.appendChild(out); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 onReceiveConstants: onReceiveConstants, | 203 onReceiveConstants: onReceiveConstants, |
200 }; | 204 }; |
201 }); | 205 }); |
202 | 206 |
203 /** | 207 /** |
204 * Initialize everything once we have access to the DOM. | 208 * Initialize everything once we have access to the DOM. |
205 */ | 209 */ |
206 window.onload = function() { | 210 window.onload = function() { |
207 media.initialize(); | 211 media.initialize(); |
208 }; | 212 }; |
OLD | NEW |