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

Side by Side Diff: content/browser/resources/media/main.js

Issue 68173025: Introduce new interface for MediaInternals updates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix JavaScript test. Use non-exported base. Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * A global object that gets used by the C++ interface. 6 * A global object that gets used by the C++ interface.
7 */ 7 */
8 var media = (function() { 8 var media = (function() {
9 'use strict'; 9 'use strict';
10 10
(...skipping 22 matching lines...) Expand all
33 }; 33 };
34 34
35 /** 35 /**
36 * Users of |media| must call initialize prior to calling other methods. 36 * Users of |media| must call initialize prior to calling other methods.
37 */ 37 */
38 media.initialize = function(theManager) { 38 media.initialize = function(theManager) {
39 manager = theManager; 39 manager = theManager;
40 }; 40 };
41 41
42 media.onReceiveEverything = function(everything) { 42 media.onReceiveEverything = function(everything) {
43 for (var key in everything.audio_streams) { 43 for (var component in everything) {
44 media.updateAudioStream(everything.audio_streams[key]); 44 media.updateAudioComponent(everything[component]);
45 } 45 }
46 }; 46 };
47 47
48 media.onReceiveConstants = function(constants) { 48 media.onReceiveConstants = function(constants) {
49 for (var key in constants.eventTypes) { 49 for (var key in constants.eventTypes) {
50 var value = constants.eventTypes[key]; 50 var value = constants.eventTypes[key];
51 eventTypes[value] = key; 51 eventTypes[value] = key;
52 } 52 }
53 53
54 for (var key in constants.eventPhases) { 54 for (var key in constants.eventPhases) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 }; 116 };
117 117
118 media.onRendererTerminated = function(renderId) { 118 media.onRendererTerminated = function(renderId) {
119 util.object.forEach(manager.players_, function(playerInfo, id) { 119 util.object.forEach(manager.players_, function(playerInfo, id) {
120 if (playerInfo.properties['render_id'] == renderId) { 120 if (playerInfo.properties['render_id'] == renderId) {
121 manager.removePlayer(id); 121 manager.removePlayer(id);
122 } 122 }
123 }); 123 });
124 }; 124 };
125 125
126 // For whatever reason, addAudioStream is also called on 126 media.updateAudioComponent = function(component) {
127 // the removal of audio streams. 127 var uniqueComponentId = component.owner_id + ':' + component.component_id;
128 media.addAudioStream = function(event) { 128 switch (component.status) {
129 switch (event.status) { 129 case 'closed':
130 case 'created': 130 manager.removeAudioComponent(
131 manager.addAudioStream(event.id); 131 component.component_type, uniqueComponentId);
132 manager.updateAudioStream(event.id, { 'playing': event.playing });
133 break; 132 break;
134 case 'closed': 133 default:
135 manager.removeAudioStream(event.id); 134 manager.updateAudioComponent(
135 component.component_type, uniqueComponentId, component);
136 break; 136 break;
137 } 137 }
138 }; 138 };
139 139
140 media.updateAudioStream = function(stream) {
141 manager.addAudioStream(stream.id);
142 manager.updateAudioStream(stream.id, stream);
143 };
144
145 media.onItemDeleted = function() {
146 // This only gets called when an audio stream is removed, which
147 // for whatever reason is also handled by addAudioStream...
148 // Because it is already handled, we can safely ignore it.
149 };
150
151 media.onPlayerOpen = function(id, timestamp) { 140 media.onPlayerOpen = function(id, timestamp) {
152 manager.addPlayer(id, timestamp); 141 manager.addPlayer(id, timestamp);
153 }; 142 };
154 143
155 media.onMediaEvent = function(event) { 144 media.onMediaEvent = function(event) {
156 var source = event.renderer + ':' + event.player; 145 var source = event.renderer + ':' + event.player;
157 146
158 // Although this gets called on every event, there is nothing we can do 147 // Although this gets called on every event, there is nothing we can do
159 // because there is no onOpen event. 148 // because there is no onOpen event.
160 media.onPlayerOpen(source); 149 media.onPlayerOpen(source);
(...skipping 25 matching lines...) Expand all
186 source, event.ticksMillis, 'EVENT', event.type); 175 source, event.ticksMillis, 'EVENT', event.type);
187 } 176 }
188 }; 177 };
189 178
190 // |chrome| is not defined during tests. 179 // |chrome| is not defined during tests.
191 if (window.chrome && window.chrome.send) { 180 if (window.chrome && window.chrome.send) {
192 chrome.send('getEverything'); 181 chrome.send('getEverything');
193 } 182 }
194 return media; 183 return media;
195 }()); 184 }());
OLDNEW
« no previous file with comments | « content/browser/resources/media/client_renderer.js ('k') | content/browser/resources/media/manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698