Android Question Exoplayer error code 400

fasilosman

Active Member
Licensed User
Longtime User
Hi all,

I tried to load a video from google drive using Exoplayer.

I got an error as..
Error: com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 400

This is my sample code..
B4X:
    player1.Initialize("player")
    player1.Prepare(player1.CreateUriSource("https://www.googleapis.com/drive/v3/files/XXXXXXXXXXXXX/?key=XXXXXXXX&alt=media"))
    SimpleExoPlayerView1.Player = player1
    player1.Play

But when I tried this link in a web browser, the MP4 file is downloaded.

Can anyone let me know the issue.

Thank you
 

drgottjr

Expert
Licensed User
Longtime User
you need the actual id of the file. the url you show is precisely for downloading. take a look at this

i think it's going to be very tricky (if possible) to obtain that id from within your app and then pass it to exoplayer. we went through several iterations of a similar situation regarding the real location of youtube videos. every time someone figured out how to parse the url, google would change it. you could conceivably get the id directly with your browser on a pc and use it with exoplayer to play the same video (or a small list of videos) over and over. but if you're thinking of storing videos on drive and "streaming" them in your app with exoplayer, it's going to be very inconvenient without a pre-built list of id's that you've managed to obtain and store in your app as a play list. that may, in fact, be exactly what you want...
 
Upvote 0

fasilosman

Active Member
Licensed User
Longtime User

Thank you. I tried. It worked. But it allows only once or twice. Then it say "user cannot download" or "download limit exceeded" or " owner and editor can download".
Then I changed sharing permission to all file to "editor" not "viewer". Now its working fine.

Now I another problem. I will ask it in a new post.

Thank you all for helping me.
 
Upvote 0

fasilosman

Active Member
Licensed User
Longtime User
Now.
After I play several videos, it is not working. I tested the link with the browser and it says
We're sorry...
... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now. See Google Help for more information.

Now I like to try it with "One drive". lets see, will it work.
 
Upvote 0
Top