How to play Music (mp3, m4a etc) from Google Drive in Flutter

1,046

So, found the solution myself :)

Two Steps:

After getting the Google Drive URL. It might look something like: https://drive.google.com/file/d/19kULSF4uayHozAdyV59kGb7Fum8SJS8s

  • Get the <FILE_ID> from Google Drive URL

In my case the <FILE_ID> is 19kULSF4uayHozAdyV59kGb7Fum8SJS8s. Its the ending portion after d/ or sometimes there is id= make sure to work according to your case.

  • Concatenate it with the link

https://drive.google.com/uc?export=view&id=`<FILE_ID>`

Finally!

That's what your link will be used as Audio.network(url) to play the audio file from Google Drive.

https://drive.google.com/uc?export=view&id=19kULSF4uayHozAdyV59kGb7Fum8SJS8s

Share:
1,046
Hamza
Author by

Hamza

I'm a Computer Sciences student in 5th Semester right now. I'm into Flutter Development for about 7-8 Months now. I'm really interested to learn: Machine Learning (TensorFlow specially) Augmented Reality (AR Core API) Other tech like, data mining, deep learning, data warehousing etc. In addition to this, I'm also a video editor and love gaming too. You can find me at different platforms as well.

Updated on December 26, 2022

Comments

  • Hamza
    Hamza 11 months

    I want to play Music Files like mp3, m4a files from Google Drive in Flutter. So far, I'm able to fetch the link of files in my google drive

    Assets I'm using

    The URL I'm getting is correct, but I don't know how would I play the music from it. Because its the URL to the file in Google drive not to the music file actually

    • The link I am getting right now: https://drive.google.com/file/d/19kULSF4uayHozAdyV59kGb7Fum8SJS8s

    • The link I actually want: cea6cf6223f140ee8037d7ba382ef034_en_GoldenTemplestory by Vanshika FormateConversion - Vanshika Mehra.mp3

    I'm not sure you will be able to access this or not, its from my organization account.

    Any help would be really appreciated :)