Open AmalBenny1 opened 1 year ago
yeah I also face this issue ...
any update ?
please refer this link, it is an issue with the permissions given in the info.plist
please refer this link, it is an issue with the permissions given in the info.plist
This did not work for me, still looking for a workaround.
The issue only occurs in iOS physical devices. It works fine in the iOS simulator. Any update?
anyone solve it?
Can anyone please confirm that in the below scenarios an error happens?
record
function.If an error isn't happening in the above-mentioned scenario, then please share the reproducible code from the example.
Having the same issue here.
Having the same issue here.
Can you please share your implementation so that we find the root cause of it.
This is my audioService. the startRecording function throws the error.
import 'package:path_provider/path_provider.dart';
class AudioService {
String? path;
String? musicFile;
bool isRecording = false;
late Directory appDirectory;
final recorderController = RecorderController()
Future<String?> stopRecording() async {
String? path = await recorderController.stop(false);
return path;
}
void resetRecording() {
recorderController.reset();
}
void startRecording() async {
if (!isRecording) {
final String fileName = locator<TrackRepository>().selectedTrack!.name + '${DateTime.now().millisecondsSinceEpoch}';
Directory? directory;
directory = await getApplicationDocumentsDirectory();
final filepath = '${directory.path}/' + fileName + ".mp3";
await recorderController.record(path: filepath);
}
}
bool getIsRecording() {
return recorderController.isRecording;
}
}```
@TNelen Thank you for the code and the issue here is that you are trying to record audio in mp3
format which is not supported by IOS's AVAudioRecorder
, So I would suggest to record in some other format which supported by native recorder & selected encoder. i.e m4a
@ujas-m-simformsolutions ah thx! Changing it to mpeg4 fixed the issue.
So what settings do I need to have in order to be able to record and share audio between Android and iOS?
The issue only occurs in iOS physical devices. It works fine in the iOS simulator. Any update?
For me the issue ain't work in iOS simulator too, is there any solution atm?.
Here's my interface implementation :
import 'package:audio_waveforms/audio_waveforms.dart';
interface class AudioController {
final RecorderController controller = RecorderController()
..androidEncoder = AndroidEncoder.aac
..androidOutputFormat = AndroidOutputFormat.mpeg4
..iosEncoder = IosEncoder.kAudioFormatMPEG4AAC;
Future<bool> get checkAudioRecordingPermission async =>
await controller.checkPermission();
bool get isRecording => controller.isRecording;
Future<void> startRecording({String? path}) async {
await controller.record(path: path); // Record (path is optional)
}
void pauseRecording() async {
await controller.pause();
}
Future<String?> stopRecording({bool callReset = true}) async {
return await controller.stop(callReset);
}
void refreshRecording({bool useShouldRefresh = false}) {
if (useShouldRefresh) {
if (controller.shouldRefresh) {
controller.refresh();
}
} else {
controller.refresh();
}
}
void disposeRecorder() async {
controller.dispose();
}
void reset() {
controller.reset();
}
}
And here's the issue that I face :
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(AudioWaveforms, Failed to prepare player, null, null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:651:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:322:18)
<asynchronous suspension>
#2 AudioWaveformsInterface.preparePlayer (package:audio_waveforms/src/base/audio_waveforms_interface.dart:100:18)
<asynchronous suspension>
#3 PlayerController.preparePlayer (package:audio_waveforms/src/controllers/player_controller.dart:122:24)
<asynchronous suspension>
#4 _VoiceMessageViewState.initState.<anonymous closure> (package:wud_patient/src/utils/chatview_package/lib/src/widgets/voice_message_view.dart:77:22)
<asynchronous suspension>
Appreciate your help!.
ok. bro
No updates for now, but I managed to download the file and prepare it from a local path and it works fine.
But is there any way to prepare or play a record from network?
Thanks
PlatformException(AudioWaveforms, Failed to start recording, null, null), just this error and the audio is not recorded and the audio waves are not shown(Working fine on android devices but issue is with IOS)