Google驱动器嵌入了无iframe [英] Google drive embed NO iframe

查看:137
本文介绍了Google驱动器嵌入了无iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



就像你可以使用YouTube视频一样:
$ b
有没有什么方法可以嵌入Google Drive视频而不使用iframe? $ b

 < object width =320height =180> 
< param name =movievalue =http://www.youtube.com/v/UHk6wFNDA5s&amp;showinfo=0>
< param name =wmodevalue =transparent>
< embed src =http://www.youtube.com/v/UHk6wFNDA5s&amp;showinfo=0type =application / x-shockwave-flashwmode =transparentwidth =320 height =180>
< / object>

来自google文档的建议嵌入代码(使用iframe)为:

 < iframe src =https://docs.google.com/file/d/0B7CQ5XvLuIGrQlJUNUhpQVltZ0U/previewwidth =640height =385 >< / iframe中> 


解决方案

这是可能的,但没有正式的支持。



在研究了Google Drive中嵌入的iframe和YouTube中的iframe的结果后,我深入研究了YouTube JS Player API,并发现可以使用嵌入SWFObject



这里是代码我用来添加播放器对象:

 函数YT_createPlayer(divId,videoId){

var params = {
allowScriptAccess:always
};

var atts = {
id:videoId
};

//将播放器URL类似于YouTube JS Player API指定的播放器URL
var videoURL ='';
videoURL + ='https://video.google.com/get_player?wmode=opaque&ps=docs&partnerid=30'; //播放器的基本URL
videoURL + ='& docid ='+ videoId; //指定文件的fileID以显示
videoURL + ='& enablejsapi = 1'; //启用Youtube Js API与视频编辑器交互
videoURL + ='& playerapiid ='+ videoId; //给视频播放器提供与视频相同的名称以备将来参考
videoURL + ='& cc_load_policy = 0; //此视频中没有标题(不支持Google云端硬盘视频)


swfobject.embedSWF(videoURL,divId,widthVideo,heightVideo,8,null,null,null,null );




$ b你需要获取 fileId 来自Google Drive的一些方法(JS或服务器端,如果您想在Google云端硬盘上托管该网站,则可以使用GAS Servlet)。



大部分YouTube播放器参数都可以使用,并且会触发控制JS播放状态的事件;所以基本上Youtube文档中的任何内容都可以工作。


Is there any way to embed google drive video without using iframes?

Just like you can do with youtube video:

<object width="320" height="180">
          <param name="movie" value="http://www.youtube.com/v/UHk6wFNDA5s&amp;showinfo=0">
          <param name="wmode" value="transparent">
          <embed src="http://www.youtube.com/v/UHk6wFNDA5s&amp;showinfo=0" type="application/x-shockwave-flash" wmode="transparent" width="320" height="180">
</object>

The suggested embed code from google docs (using iframe) is:

<iframe src="https://docs.google.com/file/d/0B7CQ5XvLuIGrQlJUNUhpQVltZ0U/preview" width="640" height="385"></iframe>

解决方案

It's possible but not officially supported.

After some study of the result generated by the iframe embed from Google Drive and the iframe from YouTube I've digged into the YouTube JS Player API and found out that it's possible using SWFObject embed

Here is the code that I use to add the player object:

function YT_createPlayer(divId, videoId) {

    var params = {
        allowScriptAccess: "always"
    };

    var atts = {
        id: videoId
    };

    //Build the player URL SIMILAR to the one specified by the YouTube JS Player API
    var videoURL = '';
    videoURL += 'https://video.google.com/get_player?wmode=opaque&ps=docs&partnerid=30'; //Basic URL to the Player
    videoURL += '&docid=' + videoId; //Specify the fileID ofthe file to show
    videoURL += '&enablejsapi=1'; //Enable Youtube Js API to interact with the video editor
    videoURL += '&playerapiid=' + videoId; //Give the video player the same name as the video for future reference
    videoURL += '&cc_load_policy=0'; //No caption on this video (not supported for Google Drive Videos)


    swfobject.embedSWF(videoURL,divId, widthVideo, heightVideo, "8", null, null, null, null);

}

You need to fetch the fileId from Google Drive some how (JS or server side, you can use a GAS Servlet if you want to host the site on Google Drive).

Most of the YouTube Player Parameters works, and events to control the playing status from JS are fired; so basically anything from the Youtube Documentation works.

这篇关于Google驱动器嵌入了无iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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