簡體   English   中英

Flutter:打開失敗:ENOENT(沒有這樣的文件或目錄)

[英]Flutter: open failed: ENOENT (No such file or directory)

Error: java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.example.sms_camera/files/recordings/1660653875334.m4a.temp: open failed: ENOENT (No such file or directory)

當我嘗試使用 flutteraudiorecorder2 停止麥克風錄音時出現此錯誤。

我已啟用Storage(WRITE_EXTERNAL_STORAGE)權限。

...
String path = '/recordings/';
    Directory appDocDirectory;
    appDocDirectory = (await getExternalStorageDirectory())!;

    path = appDocDirectory.path +
        path +
        DateTime.now().millisecondsSinceEpoch.toString();

    if (await Directory(path).exists()) {
      if (globals.kDebugMode) {
        print("Directory exists");
      }
    } else {
      if (globals.kDebugMode) {
        print("Directory doesn't exist");
      }
      await Directory(path).create(recursive: true);
    }

    var recorder =
        FlutterAudioRecorder2(path, audioFormat: AudioFormat.AAC);

    await recorder.initialized;
    await recorder.current(channel: 0);
    if (state == "start") {
      await recorder.start();
    }
    if (state == "stop") {
      await recorder.stop();
    }

該文件實際上存在,因為它是由flutteraudiorecorder創建的,我在模擬器中找到了它:單擊但每次執行代碼時,我都會在output中得到“目錄不存在”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM