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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5
6 /**
7 * A global object that gets used by the C++ interface.
8 */
9 var media = (function () {
10 'use strict';
11
12 var manager = new PlayerManager();
13
14 /**
15 * Call to modify or add a system property
16 */
17 function onSystemProperty(timestamp, key, value) {
18 console.log("System properties not yet implemented");
19 }
20
21 /**
22 * Call to modify or add a property on a player
23 */
24 function onPlayerProperty(id, timestamp, key, value) {
25 manager.updatePlayerInfo(id, timestamp, key, value);
26 }
27
28 function onPlayerPropertyNoRecord(id, timestamp, key, value) {
29 manager.updatePlayerInfoNoRecord(id, timestamp, key, value);
30 }
31
32 /**
33 * Call to add a player.
34 */
35 function onPlayerOpen(id, timestamp) {
36 manager.addPlayer(id, timestamp);
37 }
38
39 /**
40 * Call to remove a player.
41 */
42 function onPlayerClose(id) {
43 manager.removePlayer(id);
44 }
45
46 var media = {};
47 media.onSystemProperty = onSystemProperty;
48 media.onPlayerProperty = onPlayerProperty;
49 media.onPlayerPropertyNoRecord = onPlayerPropertyNoRecord;
50 media.onPlayerOpen = onPlayerOpen;
51 media.onPlayerClose = onPlayerClose;
52
53 // ----------------------------------------------
54 // Everything beyond this point is for backwards
55 // compatibility reasons. It will go away when
56 // the backend is updated.
57 // ----------------------------------------------
58
59 media.onNetUpdate = function (update) {
60 // TODO(tyoverby): Implement
61 };
62
63 media.onRendererTerminated = function (renderId) {
64 goog.object.forEach(manager.players, function (playerInfo, id) {
65 if (playerInfo.properties['render_id'] == renderId) {
66 media.onPlayerClose(id);
67 }
68 });
69 };
70
71 // For whatever reason, addAudioStream is also called on
72 // the removal of audio streams.
73 media.addAudioStream = function (event) {
74 switch (event.status) {
75 case 'created':
76 media.onPlayerOpen(event.id);
77 // We have to simulate the timestamp since
78 // it isn't provided to us.
79 media.onPlayerProperty(event.id, (new Date()).getTime(),
80 'playing', event.playing);
81 break;
82 case 'closed':
83 media.onPlayerClose(event.id);
84 break;
85 }
86 };
87 media.onItemDeleted = function () {
88 // This only gets called when an audio stream is removed, which
89 // for whatever reason is also handled by addAudioStream...
90 // Because it is already handled, we can safely ignore it.
91 };
92
93 media.onMediaEvent = function (event) {
94 var source = event.renderer + ':' + event.player;
95
96 // Although this gets called on every event, there
97 // is nothing we can do about this because there is no onOpen event.
98 media.onPlayerOpen(source);
99 media.onPlayerPropertyNoRecord(source, event.ticksMillis, 'render_id',
100 event.renderer);
101 media.onPlayerPropertyNoRecord(source, event.ticksMillis, 'player_id',
102 event.player);
103
104 var propertyCount = 0;
105 goog.object.forEach(event.params, function (value, key) {
106 key = key.trim();
107 if (key === 'buffer_start' || key === 'buffer_end' ||
108 key === 'buffer_current' || key === 'is_downloading_data') {
109 media.onPlayerPropertyNoRecord(source, event.ticksMillis, key,
110 value);
111 } else {
112 media.onPlayerProperty(source, event.ticksMillis, key, value);
113 }
114 propertyCount += 1;
115 });
116
117 if (propertyCount === 0) {
118 media.onPlayerProperty(source, event.ticksMillis, 'EVENT',
119 event.type);
120 }
121 };
122
123 return media;
124 }());
OLDNEW
« 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