flutter_sound icon indicating copy to clipboard operation
flutter_sound copied to clipboard

[BUG]:record file does not exist!!

Open jinjilynn opened this issue 3 years ago • 6 comments

flutter_sound: ^9.2.13 flutter:3.0.1 step 1: await stopRecorder() step2: get the path from future returned step3: check if exist image image

jinjilynn avatar May 24 '22 14:05 jinjilynn

after i move the record logic from bloc to widget, the record file can be saved , but the player throw platform exception when playing the local file (the player can play remote file normally), image

jinjilynn avatar May 25 '22 04:05 jinjilynn

Same

flutter_sound: ^9.2.13 Flutter: 2.10.4

LukeStanyer avatar May 25 '22 09:05 LukeStanyer

Same

flutter_sound: ^9.2.13 Flutter: 2.10.4

i have found a way, being tortured insane.you guess what,
1: the method stopRecorder() does not support creating a new directory, so the filed 'toFile' of startRecorder() should not contain another slash before the filename 2: the audio_session library is required, but not mentioned in the document

jinjilynn avatar May 25 '22 13:05 jinjilynn

  1. Yes, the file path must be either a temporary file name (without any slash) or a complete file path pointing to a valid space in which we are allowed to write. You will probably use 'path_provider' plugin to build a correct file path. If you decide to specify a temporary file name, the full path will be returned during 'closeRecorder'.
  2. Yes, 'audio session' is now very useful (since 9.0.x). Someone promised to write a guide about this, with examples, but he/she never completed this. A Pull Request by someone else is needed.

Larpoux avatar May 25 '22 13:05 Larpoux

I found that although the file exists, but it is empty.

 var filePath = await _mRecorder.stopRecorder();
  File file = File(filePath!);
  if (file.existsSync()) {
    print("file exist ${file.lengthSync()}");
  }

flutter: file exist 0

Allenxuxu avatar Jul 07 '22 15:07 Allenxuxu

  1. Yes, the file path must be either a temporary file name (without any slash) or a complete file path pointing to a valid space in which we are allowed to write. You will probably use 'path_provider' plugin to build a correct file path. If you decide to specify a temporary file name, the full path will be returned during 'closeRecorder'.
  2. Yes, 'audio session' is now very useful (since 9.0.x). Someone promised to write a guide about this, with examples, but he/she never completed this. A Pull Request by someone else is needed.

I did this fix and now the file exists but its empty too like @Allenxuxu comment

flutter_sound: ^9.2.13 issue on iOS only

LukeStanyer avatar Jul 18 '22 12:07 LukeStanyer

image I found that the file is in the tmp folder. This way can get the file in iOS.

Directory tempDir = await getTemporaryDirectory();
String path = tempDir.path.replaceAll('Library/Caches', 'tmp');
String filePath = '${path}/${_mPath}';

JeansHuang avatar Aug 21 '23 05:08 JeansHuang

This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.

github-actions[bot] avatar Dec 03 '23 01:12 github-actions[bot]