节点WebKit和YouTube:Chrome没有定义 [英] Node WebKit and YouTube: chrome is not defined

查看:214
本文介绍了节点WebKit和YouTube:Chrome没有定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 Android , iOS Mac OS Windows 使用 PhoneGap Node-WebKit 。这个应用程序嵌入了 youtube 视频。



这些 youtube 视频在我的 Mobile 应用( Android / iPhone >)使用 PhoneGap ,但是如果我在我的 Mac 上测试它(使用 grunt node-webkit builder )我得到以下错误:


未捕获ReferenceError:chrome未定义

www-embed-player.js:184


我试图检查该行,并且有一些代码:

  chrome.cast.requestSession(v(this.Lc,this)

我使用iframe嵌入视频:

 < iframe src =http://www.youtube.com/ embed / rjKRQYmi1Lkframeborder =0allowfullscreen =>< / iframe> 

知道怎么样ñ我解决它?



谢谢!

解决方案

像这与Chromecast Chrome插件有关。我假设你有

 webkit:{
plugin:true
}

,因此Chromecast插件也正在加载。然后,当它尝试与YouTube播放器进行互动时,就会失败。



尝试移除Chromecast插件,看看是否可以解决问题。如果是这样,那么你的选择是:


  1. 删除Chromecast插件,没有办法只加载节点中的特定插件-webkit,我知道。这可能不是最好的解决方案,特别是如果你分发你的应用程序。

  2. 使用其他方法加载YouTube视频。我使用JavaScript Player API,并且没有任何问题。你可以在这里找到我的例子:



    https:/ / b
    $ b

    和API参考: https://developers.google.com/youtube/js_api_reference#Embedding

    / li>
  3. 通过本地网络服务器加载您的HTML。这个错误似乎是由于使用file://协议导致的,因此使用本地web服务器加载您的HTML可能会解决此问题。我个人在方法2中使用此方法以避开受限的播放错误( https://cloudup.com/cUXiDgrYBOm )但我不确定它是否可以解决您的问题。


  4. 编辑:我意识到我得到这个错误将webkit插件设置为false,请尝试将其设置为true!当启用webkit插件时,该视频对我无影响。该错误在视频播放前会闪现。



    https:// cloudup.com/c6VyHbIyyez


    I'm developing an app for Android, iOS, Mac OS and Windows using PhoneGap and Node-WebKit. This application has embedded youtube videos.

    These youtube videos are working fine in my Mobile app (Android/iPhone) using PhoneGap, but if I test it on my Mac (building the app using grunt node-webkit builder) I get the following error:

    Uncaught ReferenceError: chrome is not defined
    www-embed-player.js:184

    I tried to check that line and there is some code like:

    chrome.cast.requestSession(v(this.Lc,this)
    

    I'm embedding the videos using an iframe:

    <iframe src="http://www.youtube.com/embed/rjKRQYmi1Lk" frameborder="0" allowfullscreen="" ></iframe>
    

    Anybody knows how can I solve it?

    Thank you!

    解决方案

    It looks like this is related to the Chromecast Chrome plugin. I'm assuming you have

    "webkit": {
        "plugin": true
    }
    

    in your manifest for flash, so the Chromecast plugin is also getting loaded. Then when it tries to interact with the YouTube player it fails.

    Try removing the Chromecast plugin to see if this resolves the issue. if so then your options are:

    1. Remove the Chromecast plugin, there isn't a way to only load specific plugins in node-webkit that I'm aware of. This may not be the best solution especially if you are distributing your app.

    2. Use another method to load the YouTube video. I use the JavaScript Player API and I don't have any issues. You can find my example here:

      https://gist.github.com/octalmage/03a054bb27d597a9f095

      And the API reference:

      https://developers.google.com/youtube/js_api_reference#Embedding

    3. Load your HTML over a local webserver. This error seems to be caused by using the file:// protocol so loading your HTML using a local webserver might resolve the issue. I personally use this with method 2 to get past the restricted playback errors (https://cloudup.com/cUXiDgrYBOm) but I'm not sure if it will fix your issue alone.

    Edit: I just realized I get this error with webkit plugin set to false, try setting it to true! The video works for me without any changes when webkit plugin is enabled. The error does flash before the video plays though.

    https://cloudup.com/c6VyHbIyyez

    这篇关于节点WebKit和YouTube:Chrome没有定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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