通过 google drive api 恢复视频 url,以便在 html5 播放器中流式传输视频 [英] Recover video url through google drive api in order to stream the video in an html5 player

查看:20
本文介绍了通过 google drive api 恢复视频 url,以便在 html5 播放器中流式传输视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到谷歌驱动器使用 Flash 播放器来传输上传的视频.

您知道 google drive api 是否提供视频的绝对 url 以便使用 html5 播放器流式传输视频?

解决方案

答案将非常类似于 这个用于嵌入图像.

所以基本上要获取可嵌入视频的 URL,您必须:

  • 在 Drive 应用程序中,当用户单击文件并使用您的应用程序打开它时,您会通过 URL 参数获取文件的 ID.
  • 使用 Drive API 和文件 ID 查询文件元数据:返回的文件元数据是一个包含一堆信息的 JSON 对象.
  • 在文件元数据中有一个名为downloadURL"的属性,它给出了实际文件的 URL.

获取文件元数据的示例是这里..p>

如果您的文件已公开共享,则可以直接访问该 URL.如果文件不公开,您将不得不使用 OAuth 2.0 来授权对该 URL 的请求.

问题:该 URL 只能暂时起作用.所以它并不适用于所有用例.

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?

解决方案

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.

这篇关于通过 google drive api 恢复视频 url,以便在 html5 播放器中流式传输视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆