如何使用javascript从谷歌驱动器播放视频?

时间:2017-04-04 17:42:47

标签: javascript google-drive-api

如何使用javascript从谷歌驱动器播放视频?

它不起作用,我该怎么做?

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>

2 个答案:

答案 0 :(得分:0)

当您从Google云端硬盘中打开/播放视频时,只需使用您在网址上看到的预览链接: 一定要包括

sandbox =&#34; allow-same-origin allow-scripts allow-popups allow-forms&#34;

  <body>
       <iframe sandbox="allow-same-origin allow-scripts allow-popups allow-forms" width="560" height="315" src="https://drive.google.com/file/d/0Bzgk4zccNwI7QkNZRnpBdExHOUk/preview?autoplay=1" frameborder="0" allowfullscreen></iframe>​
  </body>

搞定了:

enter image description here

答案 1 :(得分:0)

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

?export=download&id=YOUR_LONG_VIDEO_ID

使您能够将上传的视频插入HTML5视频标记。

这应该有效:

&#13;
&#13;
$("#play").click(function() {
   $("#video")[0].play();
});
&#13;
<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> 
&#13;
&#13;
&#13;

只需按&#34;运行代码段&#34; - 按钮即可运行此示例。希望这会有所帮助。

相关问题