【问题标题】:How to play google drive's mp3 file in fluter如何在颤振中播放谷歌驱动器 mp3 文件
【发布时间】: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


【解决方案1】:

你必须像这样为你的文件尝试直接网址

https://drive.google.com/uc?export=download&confirm=no_antivirus&id=1v8RBvEOpsEDlD_o7OA2TKgxysF-O5jUW

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多