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

Side by Side Diff: chrome/browser/resources/hotword/state_manager.js

Issue 545373005: Play a chime when the hotword is triggered. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « chrome/browser/resources/hotword/chime.wav ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 cr.define('hotword', function() { 5 cr.define('hotword', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * Class to manage hotwording state. Starts/stops the hotword detector based 9 * Class to manage hotwording state. Starts/stops the hotword detector based
10 * on user settings, session requests, and any other factors that play into 10 * on user settings, session requests, and any other factors that play into
(...skipping 25 matching lines...) Expand all
36 * @private {?hotword.constants.SessionSource} 36 * @private {?hotword.constants.SessionSource}
37 */ 37 */
38 this.sessionSource_ = null; 38 this.sessionSource_ = null;
39 39
40 /** 40 /**
41 * Callback to run when the hotword detector has successfully started. 41 * Callback to run when the hotword detector has successfully started.
42 * @private {!function()} 42 * @private {!function()}
43 */ 43 */
44 this.sessionStartedCb_ = null; 44 this.sessionStartedCb_ = null;
45 45
46 /**
47 * Hotword trigger audio notification... a.k.a The Chime (tm)
rpetterson 2014/09/16 07:55:45 nit: end with period.
48 * @private {!Audio}
49 */
50 this.chime_ = document.createElement('audio');
51
46 // Get the initial status. 52 // Get the initial status.
47 chrome.hotwordPrivate.getStatus(this.handleStatus_.bind(this)); 53 chrome.hotwordPrivate.getStatus(this.handleStatus_.bind(this));
54
55 // Setup the chime and insert into the page.
56 this.chime_.src = chrome.extension.getURL('chime.wav');
57 document.body.appendChild(this.chime_);
48 } 58 }
49 59
50 /** 60 /**
51 * @enum {number} 61 * @enum {number}
52 * @private 62 * @private
53 */ 63 */
54 StateManager.State_ = { 64 StateManager.State_ = {
55 STOPPED: 0, 65 STOPPED: 0,
56 STARTING: 1, 66 STARTING: 1,
57 RUNNING: 2, 67 RUNNING: 2,
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 230
221 /** 231 /**
222 * Handle hotword triggering. 232 * Handle hotword triggering.
223 * @private 233 * @private
224 */ 234 */
225 onTrigger_: function() { 235 onTrigger_: function() {
226 assert(this.pluginManager_); 236 assert(this.pluginManager_);
227 // Detector implicitly stops when the hotword is detected. 237 // Detector implicitly stops when the hotword is detected.
228 this.state_ = State_.STOPPED; 238 this.state_ = State_.STOPPED;
229 239
240 // Play the chime.
241 this.chime_.play();
242
230 chrome.hotwordPrivate.notifyHotwordRecognition('search', function() {}); 243 chrome.hotwordPrivate.notifyHotwordRecognition('search', function() {});
231 244
232 // Implicitly clear the session. A session needs to be started in order to 245 // Implicitly clear the session. A session needs to be started in order to
233 // restart the detector. 246 // restart the detector.
234 this.sessionSource_ = null; 247 this.sessionSource_ = null;
235 this.sessionStartedCb_ = null; 248 this.sessionStartedCb_ = null;
236 }, 249 },
237 250
238 /** 251 /**
239 * Start a hotwording session. 252 * Start a hotwording session.
(...skipping 17 matching lines...) Expand all
257 this.sessionSource_ = null; 270 this.sessionSource_ = null;
258 this.sessionStartedCb_ = null; 271 this.sessionStartedCb_ = null;
259 this.updateStateFromStatus_(); 272 this.updateStateFromStatus_();
260 } 273 }
261 }; 274 };
262 275
263 return { 276 return {
264 StateManager: StateManager 277 StateManager: StateManager
265 }; 278 };
266 }); 279 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/hotword/chime.wav ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698