问题描述
我试图使用Google Drive作为托管视频的地方,但是每当我尝试将视频用作源时,google都不会返回任何东西. (甚至没有http响应)
I tried to use google drive as a place to host videos, but whenever I try to use the video as a source, google never returns anything. (Not even a http response)
视频播放器示例
<video>
<source
src="https://www.googleapis.com/drive/v3/files/<file_id>/?alt=media&key=<api_key>"
type="video/mp4"
/>
</video>
如果我在浏览器中输入URL,它会成功提示我下载许可.
If I enter the url in the browser it successfully prompts me for permission to download.
有人知道该怎么做吗?
推荐答案
简短答案:否
更长的答案:天哪.我花了很长时间尝试自己弄清楚这一点!我正在开发一个名为 DriveStream 的项目,该项目旨在仅使用JavaScript和Apps脚本制作一个云端硬盘帐户的组织好的视频库.
Longer answer: Oh boy. I spent quite a long time trying to figure this one out myself! I'm working on a project called DriveStream, that aims to use purely JavaScript and Apps Script to make an organised video library of a Drive account.
项目本身运行良好,但是实现视频流并没有按计划进行.我尝试了几种不同的方法.一个类似于您的,另一个涉及获取文件的downloadUrl
属性并解析下载提示页面的html,以使我可以直接链接到该文件.我可以启动该文件的下载,并且可以在网络请求中看到该文件,但是无法将其流式传输到视频容器中.
The project itself works fine, but implementing video streaming did not go anywhere near as planned. I tried a few different methods. One similar to yours and the other involving getting the downloadUrl
property of a file and parsing the html of the download prompt page to give me a direct link to the file. I can initiate a download of that file, and that can be seen in the network requests, but there is no way to get it to stream into a video container.
不起作用的原因是由于AJAX的局限性.它可以从视频中返回数据,但是似乎无法将数据集中到视频容器中.
The reason that doesn't work is due to the limitations of AJAX. It can return the data from a video, but there seems to be no way to funnel that data into a video container.
最后,我不得不通过将每个视频的播放"按钮仅链接到预览视频来进行补偿.
In the end, I've had to compensate by having the 'Play' button of each video only link to the preview video.
https://drive.google.com/file/d/fileId/preview
这不是一个坏的解决方法,因为它可以播放您上传的任何内容的1080p编码.
It's not a bad workaround, as it can play up to 1080p encodes of anything you upload.
这篇关于使用Google驱动器将视频流式传输到html5播放器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!