mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-13 23:10:56 -04:00
Update event name to MIC_LISTENING
This commit is contained in:
parent
396d69743d
commit
f5edcfa3bb
2 changed files with 11 additions and 8 deletions
src
|
@ -458,12 +458,11 @@ class Runtime extends EventEmitter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Event name for requesting an update of the indicator that shows that the
|
||||
* microphone is being used to stream audio.
|
||||
* Event name to indicate that the microphone is being used to stream audio.
|
||||
* @const {string}
|
||||
*/
|
||||
static get UPDATE_MIC_INDICATOR () {
|
||||
return 'UPDATE_MIC_INDICATOR';
|
||||
static get MIC_LISTENING () {
|
||||
return 'MIC_LISTENING';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -998,8 +997,12 @@ class Runtime extends EventEmitter {
|
|||
return isConnected;
|
||||
}
|
||||
|
||||
requestMicIndicatorUpdate (visible) {
|
||||
this.emit(Runtime.UPDATE_MIC_INDICATOR, visible);
|
||||
/**
|
||||
* Emit an event to indicate that the microphone is being used to stream audio.
|
||||
* @param {boolean} listening - true if the microphone is currently listening.
|
||||
*/
|
||||
emitMicListening (listening) {
|
||||
this.emit(Runtime.MIC_LISTENING, listening);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -207,7 +207,7 @@ class Scratch3Speech2TextBlocks {
|
|||
* @private.
|
||||
*/
|
||||
_resetListening () {
|
||||
this.runtime.requestMicIndicatorUpdate(false);
|
||||
this.runtime.emitMicListening(false);
|
||||
this._stopListening();
|
||||
this._closeWebsocket();
|
||||
this._resolveSpeechPromises();
|
||||
|
@ -437,7 +437,7 @@ class Scratch3Speech2TextBlocks {
|
|||
* @private
|
||||
*/
|
||||
_startListening () {
|
||||
this.runtime.requestMicIndicatorUpdate(true);
|
||||
this.runtime.emitMicListening(true);
|
||||
this._initListening();
|
||||
// Force the block to timeout if we don't get any results back/the user didn't say anything.
|
||||
this._speechTimeoutId = setTimeout(this._stopTranscription, listenAndWaitBlockTimeoutMs);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue