2013-07-22 37 views
1

有没有什么办法嵌入谷歌驱动器视频不使用iframes?谷歌驱动器嵌入没有iframe

就像你可以在YouTube视频做:

<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> 

从谷歌文档(用IFRAME)建议的嵌入代码是:

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

回答

1

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

由谷歌驱动器的iframe嵌入,并从YouTube的iframe所产生的结果,一些研究我已经挖成的YouTube JS播放器API,并发现它可能使用SWFObject embed

这里之后是代码我用它来增加玩家的对象:

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); 

} 

您需要获取从谷歌云端硬盘fileId一些如何(JS或服务器端,您可以使用GAS Servlet的,如果你想举办的谷歌驱动的网站)。

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

+0

你好,你的剧本还在工作吗?我一直在尝试,但它不起作用,你能举一些例子吗?谢谢,问候 –

+0

嗨,该方法不工作主要是因为SWF对象使用Flash在各种浏览器上被禁用。我不认为现在有可能避免使用Iframe,但我从未在2016年夏季之后考虑过,因为各种原因(更好的性能,渐进式缓存等)将视频移至Cloud Storage。 – smokybob

-1

你的意思是这样的:

<object width="420" height="315" data="https://docs.google.com/file/d/0B7CQ5XvLuIGrQlJUNUhpQVltZ0U/preview"> 

<embed width="420" height="315" src="https://docs.google.com/file/d/0B7CQ5XvLuIGrQlJUNUhpQVltZ0U/preview"> 

我已经测试的代码和它的作品。