如何使用 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 参数,例如 export
和 id
:
?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/