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

Unified Diff: chrome/browser/resources/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: Created 9 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/media_internals.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/media_internals.js
diff --git a/chrome/browser/resources/media_internals.js b/chrome/browser/resources/media_internals.js
new file mode 100644
index 0000000000000000000000000000000000000000..2b19c7c2164b1f046384a0851adb748e382c52e6
--- /dev/null
+++ b/chrome/browser/resources/media_internals.js
@@ -0,0 +1,59 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// The <ul> holding the audio streams.
+var audioStreams;
+
+// Returns the first item in itemList with id > item.id or null if none exist.
+getFollowing = function(item, itemList) {
+ var length = itemList.length;
+ for (var i = 0; i < length; i++) {
+ if (itemList[i].id > item.id)
+ return itemList(i);
+ }
+ return null;
+};
+
+// Returns an English description of the status of |stream|.
scherkus (not reviewing) 2011/07/01 17:47:42 nit: s/an English/a text/ ?
Scott Franklin 2011/07/02 00:57:20 Done.
+audioStreamDetails = function(stream) {
+ return stream.id + ' is ' + (stream.playing ? 'playing' : 'paused') +
+ ' at ' + Math.round(stream.volume*100) + '% volume.';
scherkus (not reviewing) 2011/07/01 17:47:42 nit: spacing on *
Scott Franklin 2011/07/02 00:57:20 Done.
+};
+
+onAudioUpdate = function(args) {
+ var stream = document.getElementById(args.id);
+ if(!stream) {
scherkus (not reviewing) 2011/07/01 17:47:42 nit: spacing
Scott Franklin 2011/07/02 00:57:20 Line removed.
+ stream=document.createElement('li');
scherkus (not reviewing) 2011/07/01 17:47:42 nit: spacing on =
Scott Franklin 2011/07/02 00:57:20 Line removed.
+ stream.setAttribute('id', args.id);
+
+ // Insert the new stream into the sorted list.
+ audioStreams.insertBefore(
+ stream, getFollowing(stream, audioStreams.children));
+ }
+ stream.innerHTML = audioStreamDetails(args);
+ stream.className = args.status;
+};
+
+onReceiveEverything = function(args) {
+ for (i in args.audio_streams) {
+ for (j in args.audio_streams[i]) {
+ for (k in args.audio_streams[i][j]) {
+ onAudioUpdate(args.audio_streams[i][j][k]);
+ }
+ }
+ }
+};
+
+onItemDeleted = function(args) {
+ var stream = document.getElementById(args);
+ if(stream)
scherkus (not reviewing) 2011/07/01 17:47:42 nit: spacing
Scott Franklin 2011/07/02 00:57:20 Line removed.
+ audioStreams.removeChild(stream);
+};
+
+window.onload = function() {
+ audioStreams = document.getElementById('audio_streams');
+
+ // Get information about all currently active media.
+ chrome.send('getEverything');
+};
« no previous file with comments | « chrome/browser/resources/media_internals.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698