提交 fc04f6da authored 作者: yueweilu's avatar yueweilu

录音问题

上级 18dec114
...@@ -90,6 +90,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -90,6 +90,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
///------------------------------------------ 页面 生命周期-------------------------------------------------------- ///------------------------------------------ 页面 生命周期--------------------------------------------------------
@override @override
void onInit() async { void onInit() async {
...@@ -136,6 +137,8 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -136,6 +137,8 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
contentInput.dispose(); contentInput.dispose();
flutterTts.stop(); flutterTts.stop();
searchInput.dispose(); searchInput.dispose();
_mRecorder.closeRecorder();
_mRecorder == null;
// 关闭防截屏 // 关闭防截屏
// await ScreenProtector.preventScreenshotOff(); // await ScreenProtector.preventScreenshotOff();
super.onClose(); super.onClose();
...@@ -311,9 +314,10 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -311,9 +314,10 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
startRecording = true; startRecording = true;
String filePath = await Tools.getDirectory(); String filePath = await Tools.getDirectory();
String fileName = Tools.generateVoiceFileName(); String fileName = Tools.generateVoiceFileName();
Console.log('record---------------------$filePath/$fileName'); String recordePath = '$filePath/$fileName';
Console.log('record---------------------$recordePath');
_mRecorder.startRecorder( _mRecorder.startRecorder(
toFile: '$filePath/$fileName', toFile: recordePath,
audioSource: AudioSource.microphone, audioSource: AudioSource.microphone,
codec: Codec.aacMP4, codec: Codec.aacMP4,
...@@ -334,12 +338,15 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -334,12 +338,15 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
startRecording = false; startRecording = false;
final path = await _mRecorder.stopRecorder(); final path = await _mRecorder.stopRecorder();
Console.log('stopRecorder-----------path---------------------$path'); Console.log('stopRecorder-----------path---------------------$path');
if(path!=null && path.isNotEmpty){
var duration = await audioPlayer.setFilePath(path!); var duration = await audioPlayer.setFilePath(path!);
Console.log('-----duration---------------------$duration------'); Console.log('-----duration---------------------$duration------');
AudioModel audioModel = AudioModel(path: path,duration: Tools.formatDuration(duration!),currentDuration: '0:00:00'); AudioModel audioModel = AudioModel(path: path!,duration: Tools.formatDuration(duration!),currentDuration: '0:00:00');
if(audioModel.duration !='0:00:00'){ if(audioModel.duration !='0:00:00'){
discussInputAudios.add(audioModel); discussInputAudios.add(audioModel);
} }
}
update(); update();
} }
......
...@@ -130,7 +130,7 @@ class _ReadDiscussPageState extends State<ReadDiscussPage> { ...@@ -130,7 +130,7 @@ class _ReadDiscussPageState extends State<ReadDiscussPage> {
Visibility( Visibility(
visible: controller.showReply, visible: controller.showReply,
child: Positioned( child: Positioned(
bottom:-69, bottom:-69.w,
left: 0, left: 0,
right: 0, right: 0,
top: 0, top: 0,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论