如何在flutter中为api从record_mp3包上传mp3文件

玛丽亚姆尤尼斯

我使用这个包record_mp3记录和与此包玩纪录audioplayers,现在我要上传到API,但我不能得到记录文件只是我只有路径

这是我的录音代码

RecordMp3.instance.start(
        recordFilePath,
        (type) {
          statusText = "Record error--->$type";
          setState(() {});
        },
      );

这是我播放唱片的代码

void play() {
    if (recordFilePath != null && File(recordFilePath).existsSync()) {
      audioPlayer.play(recordFilePath, isLocal: true);
      setState(
        () {
          isPlayed = true;
        },
      );
    }
  }

所以任何人都可以帮我解决我的问题!

拉胡尔·米什拉

要获取文件的实际内容,您可以使用

Uint8List fileContent = await File(recordFilePath )
          .readAsBytes();

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章