Recover video url through google drive api in orde

2019-01-15 10:25发布

问题:

I see that google drive use a flash player in order to stream uploaded video.

Do you know if google drive api provide an absolute url to the video in order to use an html5 player to stream the video?

回答1:

The answer will be very similar to this one for embedding images.

So basically to get the URL of the embeddable video you will have to:

  • In a Drive application you get the ID of the file through a URL parameter when the user clicks on a file and opens it with your app.
  • Query the file metadata using the Drive API and the ID of the file: the file metadata returned is a JSON object containing a bunch of info.
  • In the File metadata there is an attribute called "downloadURL" which gives a URL to the actual file.

Samples to get a file metadata are here.

The URL will be directly accessible if your file has been shared publicly. If the file is not public you will have to use OAuth 2.0 to authorize requests to that URL.

Problem: That URL only works momentarily. So it's not usable for every use-case.