获得颤振音频路径后如何播放音频



我列出了设备存储的所有音频路径,现在我想从路径播放音频。这是我的listview代码

ListTile(
title: Text(files[index].path.split('/').last),
trailing: FutureBuilder<int>(
builder: (context, snapshot) {
return Text(snapshot.data.toString());
},
future: files[index].length(),
),
)

要播放音频,我个人更喜欢这个flutter插件

和一个示例用例是如下代码片段。

final player = AudioPlayer();
player.setFilePath('FILE_PATH_HERE');
player.play();                                  // Play without waiting for completion
await player.play();                            // Play while waiting for completion
await player.pause();                           // Pause but remain ready to play
await player.seek(const Duration(seconds: 10)); // Jump to the 10 second position
await player.setSpeed(2.0);                     // Twice as fast
await player.setVolume(0.5);                    // Half as loud
await player.stop();

最新更新