【问题标题】:How to get the duration of an audio file in flutter? [duplicate]如何在颤动中获取音频文件的持续时间? [复制]
【发布时间】:2023-03-28 13:40:01
【问题描述】:

我正在尝试获取音频文件的持续时间并将其设置为String。我正在使用flutter_sound 插件来播放声音。 onPlayerStateChanged listen 有持续时间,但我不知道如何使用它将String 设置为持续时间值而不播放声音。

主要目的是我想选择一个最大长度为 20 秒的音频文件。谁能帮我解决一下?

【问题讨论】:

    标签: audio flutter


    【解决方案1】:

    你可以使用:

    audioplayers: any then await audioPlayer.play(audioFile.path, isLocal: true);
    duration = await audioPlayer.getDuration();
    

    【讨论】:

    • audioplayers: any 然后等待 audioPlayer.play(audioFile.path, isLocal: true);然后这个链接返回一个持续时间 int duration = await audioPlayer.getDuration();
    猜你喜欢
    • 1970-01-01
    • 2013-03-01
    • 2011-07-10
    • 1970-01-01
    • 1970-01-01
    • 2013-10-27
    • 2014-02-08
    • 2010-11-17
    • 2020-06-02
    相关资源
    最近更新 更多