diff --git a/assets/images/sorrow_face.png b/assets/images/sorrow_face.png new file mode 100644 index 0000000..6daeaee --- /dev/null +++ b/assets/images/sorrow_face.png diff --git a/ios/Runner/XSMessageMehtodChannel.swift b/ios/Runner/XSMessageMehtodChannel.swift index d5c2e22..f6381b5 100644 --- a/ios/Runner/XSMessageMehtodChannel.swift +++ b/ios/Runner/XSMessageMehtodChannel.swift @@ -30,10 +30,10 @@ class XSMessageMehtodChannel: NSObject,SSOralEvaluatingManagerDelegate { if (!dict.keys.isEmpty) { appKey = dict["appKey"] as? String ?? "" secretKey = dict["secretKey"] as? String ?? "" + service = dict["service"] as? String ?? "" userId = dict["userId"] as? String ?? "guest" frontTime = dict["frontTime"] as? String ?? "3" backTime = dict["frontTime"] as? String ?? "3" - service = dict["service"] as? String ?? "" } let config = SSOralEvaluatingManagerConfig.init() config.vad = true @@ -102,6 +102,11 @@ class XSMessageMehtodChannel: NSObject,SSOralEvaluatingManagerDelegate { SSOralEvaluatingManager.share().stopEvaluate(); return } + + if (call.method == "cancelVoice") { + SSOralEvaluatingManager.share().cancelEvaluate(); + return; + } } //评测结果回调 diff --git a/lib/common/core/app_consts.dart b/lib/common/core/app_consts.dart index 0c47474..bb6a0c2 100644 --- a/lib/common/core/app_consts.dart +++ b/lib/common/core/app_consts.dart @@ -11,7 +11,7 @@ class AppConsts { static const String userTermSdkUrl = 'http://page.kouyuxingqiu.com/term_sdk.html'; /// 先声SDK - static String xsAppKey = BasicConfig().isTestDev?'t418':'a418'; + static String xsAppKey = 'a418'; static String xsAppSecretKey = BasicConfig().isTestDev?'1a16f31f2611bf32fb7b3fc38f5b2c81':'c11163aa6c834a028da4a4b30955be99'; static String xsAppService = BasicConfig().isTestDev?'ws://trial.cloud.ssapi.cn:8080':'"wss://api.cloud.ssapi.cn'; } diff --git a/lib/pages/repeataftercontent/bloc/repeat_after_content_bloc.dart b/lib/pages/repeataftercontent/bloc/repeat_after_content_bloc.dart index 77acfe8..1b0bc11 100644 --- a/lib/pages/repeataftercontent/bloc/repeat_after_content_bloc.dart +++ b/lib/pages/repeataftercontent/bloc/repeat_after_content_bloc.dart @@ -35,6 +35,8 @@ enum XSVoiceCheckState { unKnow, ///测评开始 start, + ///评测结果 + result, ///测评结束 stop, } @@ -111,6 +113,11 @@ class RepeatAfterContentBloc extends Bloc 准备开始录音'); await _soundRecorder.startRecorder( toFile: path, - codec: Codec.aacADTS, - bitRate: 8000, - numChannels: 1, - sampleRate: 8000, + codec: Codec.pcm16WAV, ); debugPrint('=====> 开始录音'); _voiceRecordState = VoiceRecordState.voiceRecording; diff --git a/lib/pages/repeataftercontent/repeat_after_content_page.dart b/lib/pages/repeataftercontent/repeat_after_content_page.dart index 7002d74..a425a76 100644 --- a/lib/pages/repeataftercontent/repeat_after_content_page.dart +++ b/lib/pages/repeataftercontent/repeat_after_content_page.dart @@ -27,7 +27,6 @@ class RepeatAfterContentPage extends StatelessWidget { 'appKey':AppConsts.xsAppKey, 'service':AppConsts.xsAppService, 'secretKey':AppConsts.xsAppSecretKey, - 'userId':UserUtil.getUser()!.id.toString(), } )), child: _RepeatAfterContentPage(), @@ -158,6 +157,12 @@ class _RepeatAfterContentPage extends StatelessWidget { ///播放中 Widget _buildPlayVideoWidget() { return BlocBuilder( + buildWhen: (previous, current) { + if (current is ChangeVideoPlayIndexEvent) { + return true; + } + return false; + }, builder: (context,state){ final bloc = BlocProvider.of(context); return Column( @@ -252,28 +257,46 @@ class _RepeatAfterContentPage extends StatelessWidget { builder: (context,state){ final bloc = BlocProvider.of(context); final voiceResult = bloc.voiceTestResult; + Color color; + if (int.parse(voiceResult?['overall'].toString()??'0') >= 60 || int.parse(voiceResult?['overall'].toString()??'0') <= 75) { + color = const Color(0xFFFF0000); + } else if (int.parse(voiceResult?['overall'].toString()??'0') > 75 || int.parse(voiceResult?['overall'].toString()??'0') <= 85) { + color = const Color(0xFFFFCC00); + } else { + color = const Color(0xFF40E04B); + } return Column( mainAxisAlignment: MainAxisAlignment.end, children: [ Offstage( - // offstage: false, - offstage:!(bloc.voiceRecordState == VoiceRecordState.voiceRecordEnd && bloc.xSCheckState == XSVoiceCheckState.stop), + offstage:!(bloc.voiceRecordState == VoiceRecordState.voiceRecordEnd && bloc.xSCheckState == XSVoiceCheckState.result), child: Column( children: [ - Container( - height: 45.h, - width: 45.h, - alignment: Alignment.center, - decoration: BoxDecoration( - color: const Color(0xFF40E04B), - borderRadius: BorderRadius.circular(22.5.r) + Offstage( + offstage:int.parse(voiceResult?['overall'].toString()??'0') > 60, + child: Image.asset( + 'sorrow_face'.assetPng, + height: 46.h, + width: 46.w, ), - child: Text( - voiceResult?['overall'].toString()??'0', - textAlign: TextAlign.center, - style: TextStyle( - color: Colors.white, - fontSize: 17.sp + ), + Offstage( + offstage: int.parse(voiceResult?['overall'].toString()??'0') < 60, + child: Container( + height: 45.h, + width: 45.h, + alignment: Alignment.center, + decoration: BoxDecoration( + color: color, + borderRadius: BorderRadius.circular(22.5.r) + ), + child: Text( + voiceResult?['overall'].toString()??'0', + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, + fontSize: 17.sp + ), ), ), ), @@ -299,7 +322,6 @@ class _RepeatAfterContentPage extends StatelessWidget { ), ), Offstage( - // offstage: true, offstage: bloc.voiceRecordState == VoiceRecordState.voiceRecordUnkonw || bloc.xSCheckState != XSVoiceCheckState.unKnow, child: Container( color: Colors.grey,