使用Google Apps脚本将Google云端硬盘视频嵌入Google站点中只会给我一个灰色边框 [英] Embedding Google drive videos on a Google Site using Google Apps Script just gives me a Grey Border

查看:56
本文介绍了使用Google Apps脚本将Google云端硬盘视频嵌入Google站点中只会给我一个灰色边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种编程方式,以便将Google云端硬盘中的视频添加到Google站点上.我目前的计划是为电子表格添加每行嵌入URL的种子,然后通过Google Apps脚本进行挖掘以嵌入内容.

I'm looking for a programmatic way to include videos from Google Drive on a Google Site. My current plan is to have a spreadsheet seeded with the embed URL per row that is then mined via Google Apps Script to embed the content.

但是,我认为,基于该程序的核心,我遇到了一个与

However, at the core of this program, I believe I am running into a known issue based on the similarity to http://code.google.com/p/google-apps-script-issues/issues/detail?id=1649 which was a Google bug with embedding a YouTube video on a Google Site.

如下面此URL所示,我有一个很小的HTML文件,可播放Apple的示例MP4文件,该文件已上传到Google云端硬盘,因此我可以嵌入它并可以正常工作:

As shown at this URL below, I have very small HTML file that plays Apple's example MP4 file which I uploaded to a Google Drive so I can embed it and which works as expected:

http://www.pccc.com/downloads/junk/test/test.html

但是,如果我为Apps脚本复制了相同的HTML,那么我看到的只是灰色边框,并且添加了这是测试"文本以确认发布了最新版本:

However, if I duplicate the same HTML for an Apps Script, all I see is the grey border and the "this is a test" text that was added to confirm the latest revision was published:

function doGet(e) {
  var html = '<iframe src="https://docs.google.com/a/documentshare.com/file/d/0B7wNkTj2wH_TLTdwcWo2NW5SWnM/preview" width="640" height="385"></iframe> This is a test';
  return HtmlService.createHtmlOutput(html);
}

任何指针都表示赞赏.

推荐答案

这是可行的,但方式有所不同.您可以通过脚本完全访问包含iframe的网站页面HTML.请参见重复. 首先在网站页面上手动进行插入>视频> Google文档.然后使用生成的HTML作为模板,以编程方式编写自己的模板.

This is doable but in a different way. You can have full access to a sites page HTML including iframes via script. See the doumentation. Do the edit first manually on the sites page: Insert > Video > Google docs. Then use the HTML generated as a template to write your own programmatically.

例如,请按照下列步骤操作:

For example, follow these steps:

  1. 创建一个名为TEST的网页
  2. 编辑页面并输入这是一个测试",然后插入>视频> Google文档视频(要粘贴的网址为:
  1. Create a web page called TEST
  2. Edit the page and write "this is a test" and then Insert > Video > Google Docs Video (the url to paste is: https://docs.google.com/a/documentshare.com/file/d/0B7wNkTj2wH_TLTdwcWo2NW5SWnM/preview
  3. Save the page and run this code (authorise when prompted and rerun).
  4. Refresh your page in the browser.

该代码将以编程方式更改页面,但您仍然可以正常观看视频.

The code will change the page programatically but you will still have a working video.

function myFunction() {
      //Change the domain and site to yours below
      var page = SitesApp.getSite('YOURDOMAIN', 'YOURSITE').getChildByName('TEST');
      var html = page.getHtmlContent();
      Logger.log(html);
      page.setHtmlContent(html.replace("test", "test at " + new Date()));
      var newhtml = page.getHtmlContent();
      Logger.log(newhtml);
      return;
    }

这篇关于使用Google Apps脚本将Google云端硬盘视频嵌入Google站点中只会给我一个灰色边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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