3

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 :)

3 Answers 3

9

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

6
  • Do you know anything about the bandwidth google drive provide, for example, if there are 1000 listeners listening to this file from your drive, will google charge you for that? Jan 18, 2021 at 13:48
  • Sorry sir I'm not sure of it, for me the users are 300-400 for now.
    – Hamza
    Jan 18, 2021 at 18:12
  • Okay, thanks. Please let me know if you face any trouble with this or get anything related to this from google drive. Jan 18, 2021 at 18:28
  • Yes sure why not :)
    – Hamza
    Jan 18, 2021 at 20:12
  • @Hamza. I also want to know how much listener listen to my my file.Did you get any experience?
    – Neural
    Jan 11, 2022 at 5:35
0

This is my case.

  1. Package: https://pub.dev/packages/just_audio
  2. Google drive share link: https://drive.google.com/file/d/1oXhIg5iTGwYrl9_pEPmXEJieoi_i9w9y/view?usp=sharing
  3. You must convert to: https://drive.google.com/uc?export=download&id=1oXhIg5iTGwYrl9_pEPmXEJieoi_i9w9y

Thanks to: https://www.reddit.com/r/FlutterDev/comments/o1htzt/using_google_drive/

0

You can't using this for free, for me, after some song i got this error

TYPE_SOURCE: Response code: 403

Usage limit exceeded, but maybe some of you had idea to solve this error? clear cache maybe?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.