发布YouTube视频来自Apps脚本提供的HTML内部

时间:2012-07-20 17:21:09

标签: html youtube embed google-apps-script

我正在使用

从Apps脚本提供HTML页面
    function doGet() {
      return HtmlService.createHtmlOutputFromFile('Generic.html');
    }

在Generic.html中,我尝试过几件事。 从YouTube嵌入的普通“iframe”肯定不起作用。

    <iframe width="420" height="315" src="http://www.youtube.com/embed/bTiUVMQV0Ko" frameborder="0" allowfullscreen></iframe>

尝试使用youtube上的“旧版嵌入”:

    <object width="420" height="315"><param name="movie" value="http://www.youtube.com/v/bTiUVMQV0Ko?version=3&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/bTiUVMQV0Ko?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="420" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object>

当我将旧版本直接嵌入网站html页面(而不是通过应用程序脚本提供)时,它会将其转换为Google小工具并以这种方式显示代码:

     <img src="https://www.google.com/chart?chc=sites&amp;cht=d&amp;chdp=sites&amp;chl=%5B%5BGoogle+Gadget%27%3D20%27f%5Cv%27a%5C%3D0%2710%27%3D419%270%27dim%27%5Cbox1%27b%5CF6F6F6%27fC%5CF6F6F6%27eC%5C0%27sk%27%5C%5B%22Embed+gadget%22%27%5D%27a%5CV%5C%3D12%27f%5C%5DV%5Cta%5C%3D10%27%3D0%27%3D420%27%3D312%27dim%27%5C%3D10%27%3D10%27%3D420%27%3D312%27vdim%27%5Cbox1%27b%5Cva%5CF6F6F6%27fC%5CC8C8C8%27eC%5C%27a%5C%5Do%5CLauto%27f%5C&amp;sig=lwVR4P8OQYTVXxdmEdsObNHzN2M" data-igsrc="http://0.gmodules.com/ig/ifr?mid=0&amp;synd=trogedit&amp;url=http%3A%2F%2Fwww.gstatic.com%2Fsites-gadgets%2Fembed%2Fembed.xml&amp;up_embed_snippet=%3Cobject%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%22%20height%3D%22315%22%20width%3D%22420%22%3E%3Cparam%20name%3D%22movie%22%20value%3D%22http%3A%2F%2Fwww.youtube.com%2Fv%2FbTiUVMQV0Ko%3Fversion%3D3%26amp%3Bhl%3Den_US%22%20%2F%3E%3Cparam%20name%3D%22allowFullScreen%22%20value%3D%22true%22%20%2F%3E%3Cparam%20name%3D%22allowscriptaccess%22%20value%3D%22always%22%20%2F%3E%3Cembed%20allowfullscreen%3D%22true%22%20allowscriptaccess%3D%22always%22%20height%3D%22315%22%20src%3D%22http%3A%2F%2Fwww.youtube.com%2Fv%2FbTiUVMQV0Ko%3Fversion%3D3%26amp%3Bhl%3Den_US%22%20type%3D%22application%2Fx-shockwave-flash%22%20width%3D%22420%22%20%2F%3E%3C%2Fobject%3E&amp;w=420&amp;h=315" data-type="ggs-gadget" data-props="height:315;igsrc:http#58//0.gmodules.com/ig/ifr?mid=0&amp;synd=trogedit&amp;url=http%3A%2F%2Fwww.gstatic.com%2Fsites-gadgets%2Fembed%2Fembed.xml&amp;up_embed_snippet=%3Cobject%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml%22%20height%3D%22315%22%20width%3D%22420%22%3E%3Cparam%20name%3D%22movie%22%20value%3D%22http%3A%2F%2Fwww.youtube.com%2Fv%2FbTiUVMQV0Ko%3Fversion%3D3%26amp%3Bhl%3Den_US%22%20%2F%3E%3Cparam%20name%3D%22allowFullScreen%22%20value%3D%22true%22%20%2F%3E%3Cparam%20name%3D%22allowscriptaccess%22%20value%3D%22always%22%20%2F%3E%3Cembed%20allowfullscreen%3D%22true%22%20allowscriptaccess%3D%22always%22%20height%3D%22315%22%20src%3D%22http%3A%2F%2Fwww.youtube.com%2Fv%2FbTiUVMQV0Ko%3Fversion%3D3%26amp%3Bhl%3Den_US%22%20type%3D%22application%2Fx-shockwave-flash%22%20width%3D%22420%22%20%2F%3E%3C%2Fobject%3E&amp;w=420&amp;h=315;mid:0;spec:http#58//www.gstatic.com/sites-gadgets/embed/embed.xml;up_embed_snippet:&lt;object xmlns=&quot;http#58//www.w3.org/1999/xhtml&quot; height=&quot;315&quot; width=&quot;420&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http#58//www.youtube.com/v/bTiUVMQV0Ko?version=3&amp;amp#59hl=en_US&quot; /&gt;&lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot; /&gt;&lt;param name=&quot;allowscriptaccess&quot; value=&quot;always&quot; /&gt;&lt;embed allowfullscreen=&quot;true&quot; allowscriptaccess=&quot;always&quot; height=&quot;315&quot; src=&quot;http#58//www.youtube.com/v/bTiUVMQV0Ko?version=3&amp;amp#59hl=en_US&quot; type=&quot;application/x-shockwave-flash&quot; width=&quot;420&quot; /&gt;&lt;/object&gt;;width:420;" style="display:block;text-align:left;margin-right:auto;" class="igm" height="315" width="420">

我也试过把这个放在我的Generic.html页面上,但只需获得灰色的Google Gadget屏幕。

有什么想法吗? (包括Google网站和嵌入/ iframe的任何常规解决方法)

谢谢!

1 个答案:

答案 0 :(得分:3)

Caja网站上有演示代码。此代码&#39;应该&#39;工作,但不是:

function doGet() {
  return HtmlService.createHtmlOutput(
    '<object width="240" height="195">' +
    '<param name="movie" value="http://www.youtube.com/v/unhiT2D6WvE?' +
    'version=3&hl=en_US"></param>' + 
    '<param name="allowFullScreen" value="true"></param>' + 
    '<param name="allowscriptaccess" value="always"></param>' + 
    '<embed src="http://www.youtube.com/v/unhiT2D6WvE?' + 
    'version=3&hl=en_US" type="application/x-shockwave-flash" ' + 
    'width="240" height="195" allowscriptaccess="always" allowfullscreen="true">' + 
    '</embed></object>');
}

我不清楚为什么不这样做。可能是因为我们没有正确地允许闪光通过沙箱;如果是这样我们会解决它。