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

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: Removing print hooks and inheritance. 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
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
Evan Stade 2011/07/11 21:31:52 namespace this file as well
Scott Franklin 2011/07/12 22:35:13 Done. Should the on* functions called directly by
Evan Stade 2011/07/15 22:31:05 yes, that would be choice
Scott Franklin 2011/07/15 23:18:15 Done.
5 var audioStreams = new ItemStore;
6 var audioStreamDiv;
7
8 // Render the set of audio streams to HTML and write it to the page.
9 printAudioHTML = function() {
10
11 // Render a single stream as a <li>.
12 printStream = function(stream) {
13 var out = '<li id=' + stream.id;
Evan Stade 2011/07/11 21:31:52 easier to read if you do this all via js out = do
Scott Franklin 2011/07/12 22:35:13 Unfortunately this required more fiddling with the
Evan Stade 2011/07/15 22:31:05 sorry, what do you mean?
Scott Franklin 2011/07/15 23:18:15 Just that the following lines also had to turn int
14 out += ' class="audio-stream-' + stream.status + '">';
Evan Stade 2011/07/11 21:31:52 I think it makes more sense to set the status as a
Scott Franklin 2011/07/12 22:35:13 Good idea. Done.
scherkus (not reviewing) 2011/07/13 04:17:48 Cool!
15 out += 'Audio stream ' + stream.id.split('.')[1];
16 out += ' is ' + (stream.playing ? 'playing' : 'paused');
17 out += ' at ' + Math.round(stream.volume * 100) + '% volume.';
18 out += '</li>';
19 return out;
20 };
21
22 var out = '<h2>Active audio streams:</h2>';
23 out += '<ul>';
24 out += audioStreams.map(printStream).join('');
25 out += '</ul>';
26
27 audioStreamDiv.innerHTML = out;
28 };
29
30 // Receiving data for an audio stream.
31 // Add it to audioStreams and refresh.
32 onAudioUpdate = function(stream) {
33 audioStreams.addItem(stream);
34 printAudioHTML();
35 };
36
37 // Receiving all data.
38 // Add it all to the appropriate stores and refresh.
39 onReceiveEverything = function(stuff) {
40 audioStreams.addItems(stuff.audio_streams);
41 printAudioHTML();
42 };
43
44 // Removing an item from the appropriate store.
45 onItemDeleted = function(item) {
46 var type = item.split(".")[0];
47 switch (type) {
48 case "audio_streams":
49 audioStreams.removeItem(item);
50 printAudioHTML();
51 break;
52 }
53 };
54
55 window.onload = function() {
56 audioStreamDiv = document.getElementById('audio-streams');
57
58 // Get information about all currently active media.
59 chrome.send('getEverything');
60 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698