Index: content/browser/resources/media/new/graph_painter.js |
diff --git a/content/browser/resources/media/new/graph_painter.js b/content/browser/resources/media/new/graph_painter.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b1c61b0e74c746358237a9f3ace1950148864f75 |
--- /dev/null |
+++ b/content/browser/resources/media/new/graph_painter.js |
@@ -0,0 +1,55 @@ |
+// Copyright (c) 2012 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. |
+ |
+ |
+var graphPainter = (function () { |
+ "use strict"; |
+ var graphPainter = {}; |
+ |
+ function updateBufferGraph(playerInfo, bufferGraph) { |
+ bufferGraph.setWidth(400); |
+ |
+ var p = playerInfo.properties; |
+ |
+ bufferGraph.plot(p.buffer_start, p.buffer_end); |
+ bufferGraph.plot(p.buffer_start, p.buffer_current); |
+ bufferGraph.draw(); |
+ } |
+ |
+ graphPainter.paintNew = function (playerInfo, div, options) { |
+ removeChildren(div); |
+ |
+ var p = playerInfo.properties; |
+ |
+ // If we can, make a new graph for the buffer status |
+ if (p.buffer_start !== undefined && p.buffer_current !== undefined && |
+ p.buffer_end !== undefined && p.total_bytes !== undefined) { |
+ |
+ var bufferGraph = new RangeGraph(p.total_bytes); |
+ updateBufferGraph(playerInfo, bufferGraph); |
+ bufferGraph.element.setAttribute('id', "buffer-graph"); |
+ bufferGraph.element.setAttribute('style', "vertical-align:middle;"); |
+ |
+ |
+ div.appendChild(document.createTextNode("Buffer\u00a0")); |
+ div.appendChild(bufferGraph.element); |
+ } |
+ |
+ }; |
+ graphPainter.paintExist = function (playerInfo, div, options) { |
+ var bufferGraphElem = div.querySelector("#buffer-graph"); |
+ |
+ if (bufferGraphElem) { |
+ // Use the 'existing' constructor for RangeGraph to |
+ // build it off of the existing bufferGraphElem |
+ var bufferGraph = new RangeGraph(playerInfo.properties.total_bytes, |
+ bufferGraphElem); |
+ updateBufferGraph(playerInfo, bufferGraph); |
+ } |
+ }; |
+ graphPainter.invalidate = function () { |
+ }; |
+ |
+ return graphPainter; |
+}()); |