|  |  |  | @ -970,15 +970,15 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   //////// Audio Recoding Work //////////////////// | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   Future<void> initAudio() async { | 
		
	
		
			
				|  |  |  |  |   Future<void> initAudio({required int receiverId}) async { | 
		
	
		
			
				|  |  |  |  |     appDirectory = await getApplicationDocumentsDirectory(); | 
		
	
		
			
				|  |  |  |  |     path = "${appDirectory.path}/${AppState().chatDetails!.response!.id}-${DateTime.now().microsecondsSinceEpoch}.aac"; | 
		
	
		
			
				|  |  |  |  |     path = "${appDirectory.path}/${AppState().chatDetails!.response!.id}-$receiverID-${DateTime.now().microsecondsSinceEpoch}.aac"; | 
		
	
		
			
				|  |  |  |  |     recorderController = RecorderController() | 
		
	
		
			
				|  |  |  |  |       ..androidEncoder = AndroidEncoder.aac | 
		
	
		
			
				|  |  |  |  |       ..androidOutputFormat = AndroidOutputFormat.mpeg4 | 
		
	
		
			
				|  |  |  |  |       ..iosEncoder = IosEncoder.kAudioFormatMPEG4AAC | 
		
	
		
			
				|  |  |  |  |       ..sampleRate = 8000 | 
		
	
		
			
				|  |  |  |  |       ..bitRate = 32000; | 
		
	
		
			
				|  |  |  |  |       ..sampleRate = 6000 | 
		
	
		
			
				|  |  |  |  |       ..bitRate = 18000; | 
		
	
		
			
				|  |  |  |  |     playerController = PlayerController(); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
	
		
			
				
					|  |  |  | @ -992,7 +992,6 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   void startRecoding() async { | 
		
	
		
			
				|  |  |  |  |     PermissionStatus status = await Permission.microphone.request(); | 
		
	
		
			
				|  |  |  |  |     print(status); | 
		
	
		
			
				|  |  |  |  |     if (status.isDenied == true) { | 
		
	
		
			
				|  |  |  |  |       startRecoding(); | 
		
	
		
			
				|  |  |  |  |     } else { | 
		
	
	
		
			
				
					|  |  |  | @ -1014,6 +1013,15 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  |     }); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   void _pauseTimer() { | 
		
	
		
			
				|  |  |  |  |     _timer?.cancel(); | 
		
	
		
			
				|  |  |  |  |     _timer = Timer.periodic(const Duration(seconds: 1), (Timer t) { | 
		
	
		
			
				|  |  |  |  |       _recodeDuration++; | 
		
	
		
			
				|  |  |  |  |       //  buildTimer(); | 
		
	
		
			
				|  |  |  |  |       notifyListeners(); | 
		
	
		
			
				|  |  |  |  |     }); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   Future<void> pauseRecoding() async { | 
		
	
		
			
				|  |  |  |  |     isPause = true; | 
		
	
		
			
				|  |  |  |  |     isPlaying = true; | 
		
	
	
		
			
				
					|  |  |  | @ -1025,6 +1033,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  |     await playerController.preparePlayer(file.path, 1.0); | 
		
	
		
			
				|  |  |  |  |     var tempDuration = _recodeDuration; | 
		
	
		
			
				|  |  |  |  |     _recodeDuration = tempDuration; | 
		
	
		
			
				|  |  |  |  |     _pauseTimer(); | 
		
	
		
			
				|  |  |  |  |     _timer?.cancel(); | 
		
	
		
			
				|  |  |  |  |     notifyListeners(); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
	
		
			
				
					|  |  |  | @ -1077,11 +1086,41 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   void playRecoding() async { | 
		
	
		
			
				|  |  |  |  |     isPlaying = true; | 
		
	
		
			
				|  |  |  |  |     await playerController.startPlayer(finishMode: FinishMode.stop); | 
		
	
		
			
				|  |  |  |  |     await playerController.startPlayer(finishMode: FinishMode.pause); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   void playOrPause() async { | 
		
	
		
			
				|  |  |  |  |     playerController.playerState == PlayerState.playing ? await playerController.pausePlayer() : playRecoding(); | 
		
	
		
			
				|  |  |  |  |     notifyListeners(); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   void sendVoiceMessage(BuildContext context, {required int targetUserId, required int userStatus, required String userEmail, required String targetUserName}) async { | 
		
	
		
			
				|  |  |  |  |     recorderController.pause(); | 
		
	
		
			
				|  |  |  |  |     path = await recorderController.stop(false); | 
		
	
		
			
				|  |  |  |  |     print(path); | 
		
	
		
			
				|  |  |  |  |     File voiceFile = File(path!); | 
		
	
		
			
				|  |  |  |  |     voiceFile.readAsBytesSync(); | 
		
	
		
			
				|  |  |  |  |     _pauseTimer(); | 
		
	
		
			
				|  |  |  |  |     _timer?.cancel(); | 
		
	
		
			
				|  |  |  |  |     isPause = false; | 
		
	
		
			
				|  |  |  |  |     isPlaying = false; | 
		
	
		
			
				|  |  |  |  |     isRecoding = false; | 
		
	
		
			
				|  |  |  |  |     Utils.showLoading(context); | 
		
	
		
			
				|  |  |  |  |     dynamic value = await uploadAttachments(AppState().chatDetails!.response!.id.toString(), voiceFile); | 
		
	
		
			
				|  |  |  |  |     logger.d(value); | 
		
	
		
			
				|  |  |  |  |     String? ext = getFileExtension(voiceFile.path); | 
		
	
		
			
				|  |  |  |  |     Utils.hideLoading(context); | 
		
	
		
			
				|  |  |  |  |     sendChatToServer( | 
		
	
		
			
				|  |  |  |  |         chatEventId: 2, | 
		
	
		
			
				|  |  |  |  |         fileTypeId: getFileType(ext.toString()), | 
		
	
		
			
				|  |  |  |  |         targetUserId: targetUserId, | 
		
	
		
			
				|  |  |  |  |         targetUserName: targetUserName, | 
		
	
		
			
				|  |  |  |  |         isAttachment: true, | 
		
	
		
			
				|  |  |  |  |         chatReplyId: null, | 
		
	
		
			
				|  |  |  |  |         isReply: false, | 
		
	
		
			
				|  |  |  |  |         isImageLoaded: true, | 
		
	
		
			
				|  |  |  |  |         image: voiceFile.readAsBytesSync()); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     notifyListeners(); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | } | 
		
	
	
		
			
				
					|  |  |  | 
 |