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

Side by Side Diff: chrome/browser/resources/media_internals/media_internals.js

Issue 7273089: Display active audio streams on chrome://media-internals. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Nitpicking, reordering methods. Created 9 years, 5 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 | « chrome/browser/resources/media_internals/media_internals.css ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 cr.define('media', function() {
6
7 var audioStreams = new media.ItemStore;
8 var audioStreamDiv;
Evan Stade 2011/07/15 23:38:58 document these vars
Scott Franklin 2011/07/16 00:07:32 Done.
9
10 /**
11 * Initialize variables and ask MediaInternals for all its data.
12 */
13 initialize = function() {
14 audioStreamDiv = document.getElementById('audio-streams');
15 // Get information about all currently active media.
16 chrome.send('getEverything');
17 };
18
19 /**
20 * Write the set of audio streams to the DOM.
21 */
22 printAudioStreams = function() {
23
24 /**
25 * Render a single stream as a <li>.
26 * @param {Object} stream The stream to render.
27 * @return {HTMLElement} A <li> containing the stream information.
28 */
29 printStream = function(stream) {
30 var out = document.createElement('li');
31 out.id = stream.id;
32 out.className = 'audio-stream';
33 out.setAttribute('status', stream.status);
34
35 out.innerHTML += 'Audio stream ' + stream.id.split('.')[1];
36 out.innerHTML += ' is ' + (stream.playing ? 'playing' : 'paused');
37 out.innerHTML += ' at ' + Math.round(stream.volume * 100) + '% volume.';
38 return out;
39 };
40
41 var out = document.createElement('ul');
42 audioStreams.map(printStream).forEach(function(s) { out.appendChild(s) });
Evan Stade 2011/07/15 23:38:58 I believe the proper spacing is audioStreams.map(
Scott Franklin 2011/07/16 00:07:32 Done.
43
44 if (audioStreamDiv.firstChild)
Evan Stade 2011/07/15 23:38:58 audioStreamDiv.textContent = '';
Scott Franklin 2011/07/16 00:07:32 Done, both in the if and below.
45 audioStreamDiv.removeChild(audioStreamDiv.firstChild);
46 audioStreamDiv.appendChild(out);
47 };
48
49 /**
50 * Receiving data for an audio stream.
51 * Add it to audioStreams and refresh.
52 * @param {Object} stream JSON representation of an audio stream.
53 */
54 onAudioUpdate = function(stream) {
Evan Stade 2011/07/15 23:38:58 I think addAudioStream is a more appropriate name
Scott Franklin 2011/07/16 00:07:32 Done.
55 media.audioStreams.addItem(stream);
56 media.printAudioStreams();
57 };
58
59 /**
60 * Receiving all data.
61 * Add it all to the appropriate stores and refresh.
Evan Stade 2011/07/15 23:38:58 I don't understand 'refresh' in this context. Do y
Scott Franklin 2011/07/16 00:07:32 It was an attempt to describe the operation of wri
62 *
Evan Stade 2011/07/15 23:38:58 remove
Scott Franklin 2011/07/16 00:07:32 Done.
63 * @param {Object} stuff JSON containing lists of data.
64 * @param {Object} stuff.audio_streams A dictionary of audio streams.
65 */
66 onReceiveEverything = function(stuff) {
67 media.audioStreams.addItems(stuff.audio_streams);
68 media.printAudioStreams();
69 };
70
71 /**
72 * Removing an item from the appropriate store.
73 * @param {string} id The id of the item to be removed, in the format
74 * "item_type.identifying_info".
75 */
76 onItemDeleted = function(id) {
77 var type = id.split('.')[0];
78 switch (type) {
79 case 'audio_streams':
80 media.audioStreams.removeItem(id);
81 media.printAudioStreams();
82 break;
83 }
84 };
85
86 return {
87 initialize: initialize,
88 printAudioStreams: printAudioStreams,
89 onAudioUpdate: onAudioUpdate,
90 onReceiveEverything: onReceiveEverything,
91 onItemDeleted: onItemDeleted,
92 audioStreams: audioStreams
93 };
94 });
95
96 /**
97 * Initialize everything once we have access to the DOM.
98 */
99 window.onload = function() {
100 media.initialize();
101 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/media_internals/media_internals.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698