Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in Ios this not work #11

Open
dp77 opened this issue Jun 6, 2024 · 0 comments
Open

in Ios this not work #11

dp77 opened this issue Jun 6, 2024 · 0 comments

Comments

@dp77
Copy link

dp77 commented Jun 6, 2024

IN iOS i get this error

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PathNotFoundException: Cannot copy file to '/var/mobile/Containers/Data/Application/9F2B9984-B1FC-495F-9A54-A915B817BEC7/Documents/recording_1717674447834.wav', path = '/var/mobile/Containers/Data/Application/9F2B9984-B1FC-495F-9A54-A915B817BEC7/Documents66618cc11d183d64ab2ec6391717674427138.wav' (OS Error: No such file or directory, errno = 2)
#0 _checkForErrorResponse (dart:io/common.dart:55:9)
#1 _File.copy. (dart:io/file_impl.dart:356:7)

#2 _MessageScreenState.sendMediaMessage (package:privacyport/ui/chat/message_screen.dart:1793:20)

i give the permission also

NSMicrophoneUsageDescription
Can We Use Your Microphone Please

This is my function

void _initRecorder() async {
if (await AnotherAudioRecorder.hasPermissions) {
String customPath = chatId;
Directory appDocDirectory;
if (Platform.isIOS) {
appDocDirectory = await getApplicationDocumentsDirectory();
} else {
appDocDirectory = (await getExternalStorageDirectory())!;
}
customPath = appDocDirectory.path + customPath + DateTime.now().millisecondsSinceEpoch.toString();

  _recorder = AnotherAudioRecorder(customPath, audioFormat: AudioFormat.WAV);
  await _recorder?.initialized;
} else {
  print("Permissions not granted");
}

}

this is how i used this

                          GestureDetector(
                            onTap: () {
                              if (newMessageController.text.isEmpty) return;
                              if (group) {
                                sendGroupMessage();
                              } else {
                                sendMessage();
                              }
                            },
                            onLongPress: () async {
                              if (newMessageController.text.isEmpty) {
                                animationController
                                  ..forward()
                                  ..repeat(reverse: true);
                                await _recorder?.start();
                              }
                              print('onLongPress');
                            },
                            onLongPressEnd: (details) {
                              animationController.stop();
                              animationController.reset();
                              stopRecording();
                              print('onLongPressEnd');
                            },
                            child: AnimatedBuilder(
                              animation: animationController,
                              builder: (context, child) {
                                return Transform.scale(
                                  scale: 1 + animationController.value * 0.5,
                                  // Adjust the scale factor as needed
                                  child: child,
                                );
                              },
                              child: SizedBox(
                                height: 45,
                                width: 45,
                                child: Image.asset(
                                  newMessageController.text.isEmpty ? VOICE : SEND,
                                ),
                              ),
                            ),
                          ),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant