OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 Loading... | |
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 }); |
OLD | NEW |