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

Unified Diff: content/browser/resources/media/main/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: 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/main/main.js
diff --git a/content/browser/resources/media/main/main.js b/content/browser/resources/media/main/main.js
new file mode 100755
index 0000000000000000000000000000000000000000..d45dbeae202a2c34f886a90a93a2f0a4bb39ea04
--- /dev/null
+++ b/content/browser/resources/media/main/main.js
@@ -0,0 +1,122 @@
+/**
+ * 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);
+ }
+
+ // TODO(toverby): If you get a media event that doesn't have any properties,
+ // do something with the |type| of the event.
+
+ 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;
+}());

Powered by Google App Engine
This is Rietveld 408576698