【发布时间】:2020-09-12 09:23:26
【问题描述】:
我已经在我的谷歌驱动器中上传了一些 mp3 文件。现在我想使用 audioplayers 包在我的颤振应用程序中播放这些 mp3 文件。 https://drive.google.com/file/d/1v8RBvEOpsEDlD_o7OA2TKgxysF-O5jUW/view?usp=sharing。这是我在 google drive 中的 mp3 的公开可共享链接。
void getAudio() async {
var url =
"https://drive.google.com/file/d/1v8RBvEOpsEDlD_o7OA2TKgxysF-O5jUW/view?usp=sharing";
if (isPlaying) {
var res = await audioPlayer.pause();
if (res == 1) {
print("isPlaying $res");
setState(() {
isPlaying = false;
});
}
} else {
var res = await audioPlayer.play(url, isLocal: false);
print("!isPlaying $res");
if (res == 1) {
setState(() {
isPlaying = true;
});
}
}
audioPlayer.onDurationChanged.listen((Duration d) {
setState(() {
duration = d;
});
});
audioPlayer.onAudioPositionChanged.listen((Duration d) {
setState(() {
position = d;
});
});
}
【问题讨论】:
-
嘿,你找到方法了吗?
标签: flutter audio google-drive-api native