javascript - 如何使用 JavaScript 播放 Google Drive 中的视频?

标签 javascript google-drive-api

如何使用 JavaScript 播放 Google Drive 中的视频?

这不起作用,我该怎么办?

http://fiddle.jshell.net/gt4otyfk/1/

<script type="text/javascript">
    $(function(){
        var video = $("#video").get(0);
        video.controls = true;
        $("#play").click(function() {
            video.play();
        });
    });
</script>

最佳答案

Google 通过 google-drive 提供了一些 GET 参数,例如 exportid:

?export=download&id=YOUR_LONG_VIDEO_ID

让您能够将上传的视频插入 HTML5 视频标签。

这应该有效:

$("#play").click(function() {
   $("#video")[0].play();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<button id="play" style="margin-top: 300px;">Play</button>

<video id="video" width="320" height="240" controls>
   <source src="https://drive.google.com/uc?export=download&id=0B8-qLYDzDfCyRF9vOE9sWmx5YjA" type='video/mp4'>
   Your browser does not support the video tag.
</video> 

只需按“运行代码片段”按钮即可运行此示例。希望这会有所帮助。

关于javascript - 如何使用 JavaScript 播放 Google Drive 中的视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43214124/

相关文章:

Javascript:无法打印由 Object.defineProperty 定义的对象属性

javascript - 在页面加载时跟踪 JS CSS 资源错误

javascript - 如何使用 api key 访问 Google Drive

javascript - tinyMCE iframe 或表格高度未正确调整大小

javascript - 在异步 Mocha 测试中将 Assets 放在哪里

javascript - 根据值从索引数组中删除元素

android - Google Drive SDK - 在上传完成时获取资源 ID

node.js - Nodejs 脚本不读取 GDOC 文件扩展名

python - 谷歌电子表格 API : 'SpreadsheetsClient' object has no attribute 'update_cell'

php - 如何使用 Google Drive Api v3 和 php 显示文本文件的内容?