Skip to content

Commit

Permalink
修复bug
Browse files Browse the repository at this point in the history
增加stop方法
  • Loading branch information
jlcool committed Aug 3, 2019
1 parent a5062fd commit f41a9bd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,36 @@ private FlutterTaiPlugin(Registrar registrar, Activity activity) {
public void onMethodCall(MethodCall call, Result result) {
if (call.method.equals("record")) {
onRecord(call, result);
} else {
} else if (call.method.equals("stop")) {
onStop(call, result);
} else{
result.notImplemented();
}
}

public void onStop(final MethodCall call, final Result result) {
final String _id= call.argument("id");
if (_oral.isRecording()) {
_oral.stopRecordAndEvaluation(new TAIOralEvaluationCallback() {
@Override
public void onResult(final TAIError error) {
Gson gson = new Gson();
String string = gson.toJson(error);
final Map<String, String> _data = new HashMap();
_data.put("id", _id);
_data.put("err", string);
activity.runOnUiThread(
new Runnable() {
@Override
public void run() {
_channel.invokeMethod("onStop", _data);
}
});

}
});
}
}
public void onRecord(final MethodCall call, final Result result) {

final Result _result = result;
Expand Down
8 changes: 5 additions & 3 deletions lib/flutter_tai.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ class FlutterTai {
break;
}
}

Future stop()async{
await _invokeMethod('stop');
}
Future record(String appId, String secretId, String secretKey, String refText,
{String soeAppId = "",
String token = "",
Expand All @@ -90,9 +92,9 @@ class FlutterTai {
int timeout = -1,
int retryTimes = -1,
double fragSize = 1,
bool fragEnable = false,
bool fragEnable = true,
bool vadEnable = true,
int vadInterval = 4000}) async {
int vadInterval = 3000}) async {
if (workMode == TAIOralEvaluationWorkMode.STREAM) {
timeout = timeout == -1 ? 5 : timeout;
retryTimes = retryTimes == -1 ? 5 : retryTimes;
Expand Down

0 comments on commit f41a9bd

Please sign in to comment.