Skip to content

Commit

Permalink
Merge pull request #175 from liviu-padurariu/feature/androidProgress
Browse files Browse the repository at this point in the history
Android tts-progress event.
  • Loading branch information
ak1394 authored Mar 25, 2021
2 parents 442a6f5 + 525bac6 commit ca32705
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions android/src/main/java/net/no_mad/tts/TextToSpeechModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ public void onStop(String utteranceId, boolean interrupted) {
}
sendEvent("tts-cancel", utteranceId);
}

@Override
public void onRangeStart (String utteranceId, int start, int end, int frame) {
WritableMap params = Arguments.createMap();
params.putString("utteranceId", utteranceId);
params.putInt("start", start);
params.putInt("end", end);
params.putInt("frame", frame);
sendEvent("tts-progress", params);
}
});
}
}
Expand Down Expand Up @@ -507,6 +517,10 @@ private int speak(String utterance, String utteranceId, ReadableMap inputParams)
private void sendEvent(String eventName, String utteranceId) {
WritableMap params = Arguments.createMap();
params.putString("utteranceId", utteranceId);
sendEvent(eventName, params);
}

private void sendEvent(String eventName, WritableMap params) {
getReactApplicationContext()
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit(eventName, params);
Expand Down

0 comments on commit ca32705

Please sign in to comment.