'How to play Music (mp3, m4a etc) from Google Drive in Flutter
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 :)
Solution 1:[1]
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
Solution 2:[2]
This is my case.
- Package: https://pub.dev/packages/just_audio
- Google drive share link: https://drive.google.com/file/d/1oXhIg5iTGwYrl9_pEPmXEJieoi_i9w9y/view?usp=sharing
- 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/
Solution 3:[3]
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?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Dharman |
Solution 3 | mamena tech |