Youtube 谷歌驱动器嵌入没有iframe
有没有办法在不使用iFrame的情况下嵌入google drive视频 就像youtube视频一样:Youtube 谷歌驱动器嵌入没有iframe,youtube,google-drive-api,Youtube,Google Drive Api,有没有办法在不使用iFrame的情况下嵌入google drive视频 就像youtube视频一样: <object width="320" height="180"> <param name="movie" value="http://www.youtube.com/v/UHk6wFNDA5s&showinfo=0"> <param name="wmode" value="transparent">
<object width="320" height="180">
<param name="movie" value="http://www.youtube.com/v/UHk6wFNDA5s&showinfo=0">
<param name="wmode" value="transparent">
<embed src="http://www.youtube.com/v/UHk6wFNDA5s&showinfo=0" type="application/x-shockwave-flash" wmode="transparent" width="320" height="180">
</object>
谷歌文档(使用iframe)中建议的嵌入代码是:
这是可能的,但没有官方支持 在对Google Drive中嵌入的iframe和YouTube中嵌入的iframe生成的结果进行了一些研究之后,我深入研究了YouTube JS Player API,发现使用 下面是我用来添加播放器对象的代码:
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);
}
您需要从Google Drive获取文件ID
(JS或服务器端,如果您想在Google Drive上托管站点,可以使用GAS Servlet)
大多数YouTube播放器参数都能正常工作,并触发了控制JS播放状态的事件;因此,Youtube文档中的任何内容基本上都是有效的。你的意思是:
<object width="420" height="315" data="https://docs.google.com/file/d/0B7CQ5XvLuIGrQlJUNUhpQVltZ0U/preview">
我已经对代码进行了测试,它可以正常工作。我使用了中的示例代码,但无法将代码粘贴到此处,因为它是他们的,只需按照链接查看即可 第二部分是获得正确的图像链接。我发现直接从驱动器使用链接不起作用,所以我在我的网站上创建了一个新页面,并添加了我想要的所有图像。我禁用了导航页面,因此除非他们使用搜索,否则无法找到该页面。发布后,我打开页面并使用浏览器上的Inspect查找每个图像的标记。然后我复制了看起来像这样的元素
<img src="https://lh3.googleusercontent.com/qt ... 4jM=w1175" class="CENy8b" role="img" style="width: 100%; margin: 0%">
我添加了title属性,因此可以查看包含哪些图像。我还删除了class=“CENy8b”属性,因为它似乎不是必需的
<img src="https://lh3.googleusercontent.com/qt ... 4jM=w1175" role="img" style="width: 100%; margin: 0%" title = "image 1">
然后我将其粘贴在W3Schools代码中的标记上,对每个图像重复。W3Schools代码有一个标记,在该标记的图像下有点,以显示正在显示的图像集中的哪个图像。点的数量需要与图像的数量相匹配
完成以上所有操作后,我从编辑器中复制了代码,并在站点上使用嵌入代码来粘贴它。您可以在站点编辑器中看到这些图像,在发布后,它们可以在live页面上正常工作
代码在两个图像之间使用2秒的延迟。很容易找到代码中的设置位置,以便将其更改为适合您的站点的适当值。您好,您的脚本仍然有效吗?我试过了,但没用,你能举个例子吗?谢谢你,RegardsHi,这个方法主要不起作用,因为SWF对象使用Flash,而Flash在各种浏览器上都是禁用的。我认为现在不可能避免使用iFrame,但在2016年夏季之后,我从未考虑过它,当时我们出于各种原因(更好的性能、渐进式缓存等)将视频移动到云存储
<img src="https://lh3.googleusercontent.com/qt ... 4jM=w1175" class="CENy8b" role="img" style="width: 100%; margin: 0%">
<img src="https://lh3.googleusercontent.com/qt ... 4jM=w1175" role="img" style="width: 100%; margin: 0%" title = "image 1">