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

Unified Diff: content/browser/resources/media/new/main.js

Issue 18889006: Removed old media-internals page and rewrote it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved all 'new' media internals files into its own folder for a smooth transition. Created 7 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/resources/media/new/main.js
diff --git a/content/browser/resources/media/new/main.js b/content/browser/resources/media/new/main.js
new file mode 100644
index 0000000000000000000000000000000000000000..9ac7295375f1e495c3e497a703b792b6ade0bd64
--- /dev/null
+++ b/content/browser/resources/media/new/main.js
@@ -0,0 +1,124 @@
+// 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.
+
+
+/**
+ * A global object that gets used by the C++ interface.
+ */
+var media = (function () {
+ 'use strict';
+
+ var manager = new PlayerManager();
+
+ /**
+ * Call to modify or add a system property
+ */
+ function onSystemProperty(timestamp, key, value) {
+ console.log("System properties not yet implemented");
+ }
+
+ /**
+ * Call to modify or add a property on a player
+ */
+ function onPlayerProperty(id, timestamp, key, value) {
+ manager.updatePlayerInfo(id, timestamp, key, value);
+ }
+
+ function onPlayerPropertyNoRecord(id, timestamp, key, value) {
+ manager.updatePlayerInfoNoRecord(id, timestamp, key, value);
+ }
+
+ /**
+ * Call to add a player.
+ */
+ function onPlayerOpen(id, timestamp) {
+ manager.addPlayer(id, timestamp);
+ }
+
+ /**
+ * Call to remove a player.
+ */
+ function onPlayerClose(id) {
+ manager.removePlayer(id);
+ }
+
+ var media = {};
+ media.onSystemProperty = onSystemProperty;
+ media.onPlayerProperty = onPlayerProperty;
+ media.onPlayerPropertyNoRecord = onPlayerPropertyNoRecord;
+ media.onPlayerOpen = onPlayerOpen;
+ media.onPlayerClose = onPlayerClose;
+
+ // ----------------------------------------------
+ // Everything beyond this point is for backwards
+ // compatibility reasons. It will go away when
+ // the backend is updated.
+ // ----------------------------------------------
+
+ media.onNetUpdate = function (update) {
+ // TODO(tyoverby): Implement
+ };
+
+ media.onRendererTerminated = function (renderId) {
+ goog.object.forEach(manager.players, function (playerInfo, id) {
+ if (playerInfo.properties['render_id'] == renderId) {
+ media.onPlayerClose(id);
+ }
+ });
+ };
+
+ // For whatever reason, addAudioStream is also called on
+ // the removal of audio streams.
+ media.addAudioStream = function (event) {
+ switch (event.status) {
+ case 'created':
+ media.onPlayerOpen(event.id);
+ // We have to simulate the timestamp since
+ // it isn't provided to us.
+ media.onPlayerProperty(event.id, (new Date()).getTime(),
+ 'playing', event.playing);
+ break;
+ case 'closed':
+ media.onPlayerClose(event.id);
+ break;
+ }
+ };
+ media.onItemDeleted = function () {
+ // This only gets called when an audio stream is removed, which
+ // for whatever reason is also handled by addAudioStream...
+ // Because it is already handled, we can safely ignore it.
+ };
+
+ media.onMediaEvent = function (event) {
+ var source = event.renderer + ':' + event.player;
+
+ // Although this gets called on every event, there
+ // is nothing we can do about this because there is no onOpen event.
+ media.onPlayerOpen(source);
+ media.onPlayerPropertyNoRecord(source, event.ticksMillis, 'render_id',
+ event.renderer);
+ media.onPlayerPropertyNoRecord(source, event.ticksMillis, 'player_id',
+ event.player);
+
+ var propertyCount = 0;
+ goog.object.forEach(event.params, function (value, key) {
+ key = key.trim();
+ if (key === 'buffer_start' || key === 'buffer_end' ||
+ key === 'buffer_current' || key === 'is_downloading_data') {
+ media.onPlayerPropertyNoRecord(source, event.ticksMillis, key,
+ value);
+ } else {
+ media.onPlayerProperty(source, event.ticksMillis, key, value);
+ }
+ propertyCount += 1;
+ });
+
+ if (propertyCount === 0) {
+ media.onPlayerProperty(source, event.ticksMillis, 'EVENT',
+ event.type);
+ }
+ };
+
+ return media;
+}());
« no previous file with comments | « content/browser/resources/media/new/log_painter.js ('k') | content/browser/resources/media/new/media_internals.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698