Commit 1ff9dac2 authored by sail@chromium.org's avatar sail@chromium.org

Handle no volume in chrome://media-internals

When using Pepper Flash chrome://media-internals displays NaN for volume.

Volume may never be set by plugins like Pepper Flash. Fix is to only display volume information if it exists.

(Also fixed presubmit errors.)

BUG=64215
TEST=Ran on youtube and verified that volume wasn't displayed. Ran on music.google.com and verified that volume was displayed.

Review URL: https://chromiumcodereview.appspot.com/10821058

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149228 0039d316-1c4b-4281-b951-d872f2087c98
parent fa59bc9b
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html i18n-values="dir:textdirection;"> <html i18n-values="dir:textdirection;">
<!-- <!--
Copyright (c) 2011 The Chromium Authors. All rights reserved. Copyright (c) 2012 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. found in the LICENSE file.
--> -->
...@@ -9,6 +9,7 @@ found in the LICENSE file. ...@@ -9,6 +9,7 @@ found in the LICENSE file.
<link rel="stylesheet" href="media_internals/media_internals.css" /> <link rel="stylesheet" href="media_internals/media_internals.css" />
<script src="chrome://resources/js/cr.js"></script> <script src="chrome://resources/js/cr.js"></script>
<script src="chrome://resources/js/cr/ui.js"></script> <script src="chrome://resources/js/cr/ui.js"></script>
<script src="chrome://resources/js/util.js"></script>
<script src="chrome://media-internals/media_internals.js"></script> <script src="chrome://media-internals/media_internals.js"></script>
<script src="chrome://media-internals/strings.js"></script> <script src="chrome://media-internals/strings.js"></script>
<title>Media Internals</title> <title>Media Internals</title>
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -41,8 +41,8 @@ cr.define('media', function() { ...@@ -41,8 +41,8 @@ cr.define('media', function() {
* Initialize variables and ask MediaInternals for all its data. * Initialize variables and ask MediaInternals for all its data.
*/ */
function initialize() { function initialize() {
audioStreamDiv = document.getElementById('audio-streams'); audioStreamDiv = $('audio-streams');
cacheDiv = document.getElementById('cache-entries'); cacheDiv = $('cache-entries');
// Get information about all currently active media. // Get information about all currently active media.
chrome.send('getEverything'); chrome.send('getEverything');
...@@ -66,14 +66,16 @@ cr.define('media', function() { ...@@ -66,14 +66,16 @@ cr.define('media', function() {
out.textContent += 'Audio stream ' + stream.id.split('.')[1]; out.textContent += 'Audio stream ' + stream.id.split('.')[1];
out.textContent += ' is ' + (stream.playing ? 'playing' : 'paused'); out.textContent += ' is ' + (stream.playing ? 'playing' : 'paused');
out.textContent += ' at ' + (stream.volume * 100).toFixed(0); if (typeof stream.volume != 'undefined') {
out.textContent += '% volume.'; out.textContent += ' at ' + (stream.volume * 100).toFixed(0);
out.textContent += '% volume.';
}
return out; return out;
} }
var out = document.createElement('ul'); var out = document.createElement('ul');
audioStreams.map(printStream).forEach(function(s) { audioStreams.map(printStream).forEach(function(s) {
out.appendChild(s) out.appendChild(s);
}); });
audioStreamDiv.textContent = ''; audioStreamDiv.textContent = '';
...@@ -147,7 +149,7 @@ cr.define('media', function() { ...@@ -147,7 +149,7 @@ cr.define('media', function() {
function onRendererTerminated(renderer) { function onRendererTerminated(renderer) {
for (var key in mediaPlayers) { for (var key in mediaPlayers) {
if (mediaPlayers[key].renderer == renderer) { if (mediaPlayers[key].renderer == renderer) {
document.getElementById('media-players').removeChild(mediaPlayers[key]); $('media-players').removeChild(mediaPlayers[key]);
delete mediaPlayers[key]; delete mediaPlayers[key];
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment