控制在node-webkit中打开flash的窗口

时间:2013-11-05 19:48:10

标签: javascript node.js flash node-webkit

我将youtube视频嵌入到node-webkit 无框架应用中, 每当点击视频中的YouTube链接时,预期的行为是在默认浏览器中打开网址,但它的作用是创建一个新的node-webkit 无框架窗口,它位于我的顶部。应用程序。 iv'e尝试重写window.open但这没有用,因为flash可能会使用其他api来启动一个新窗口,我正在寻找的方法是完全禁用新窗口,或者每次都能拦截将打开一个新窗口,并将该URL重定向到默认浏览器。 我看了api,似乎javascript没有暴露给具有所有窗口实例的浏览器进程。

有关如何解决此问题的任何想法?

编辑: 好的,有一种方法可以禁用flash调用navigateToURL它是你添加到<param name="allowNetworking" value="internal"/>的一个参数,虽然这不是理想的,这有助于用户体验。资料来源:http://livedocs.adobe.com/flex/3/html/help.html?content=wrapper_13.html

第二次编辑: 我发现的另一个错误是第二个弹出窗口完全崩溃了node-webkit,这就是控制台没有输出任何有用的东西:

2013-11-07 22:42:52.435 node-webkit[78145:507] Internals of CFAllocator not known; out-of-memory failures via CFAllocator will not result in termination. http://crbug.com/45650
2013-11-07 22:42:52.609 node-webkit Helper[78146:507] Internals of CFAllocator not known; out-of-memory failures via CFAllocator will not result in termination. http://crbug.com/45650
2013-11-07 22:42:52.803 node-webkit Helper EH[78147:507] Internals of CFAllocator not known; out-of-memory failures via CFAllocator will not result in termination. http://crbug.com/45650
2013-11-07 22:42:52.932 node-webkit Helper EH[78148:507] Internals of CFAllocator not known; out-of-memory failures via CFAllocator will not result in termination. http://crbug.com/45650
[78148:1107/224252:INFO:plugin_main_mac.mm(22)] No Carbon Interpose library found.
2013-11-07 22:42:53.103 node-webkit Helper[78149:507] Internals of CFAllocator not known; out-of-memory failures via CFAllocator will not result in termination. http://crbug.com/45650
[78145:1107/224253:INFO:simple_index_file.cc(397)] Simple Cache Index is being restored from disk.
2013-11-07 22:42:53.653 node-webkit Helper[78151:507] Internals of CFAllocator not known; out-of-memory failures via CFAllocator will not result in termination. http://crbug.com/45650
2013-11-07 22:42:54.036 node-webkit Helper EH[78148:507] CoreText performance note: Client called CTFontCreateWithName() using name "Arial Unicode MS" and got font with PostScript name "ArialUnicodeMS". For best performance, only use PostScript names when calling this API.
2013-11-07 22:42:54.036 node-webkit Helper EH[78148:507] CoreText performance note: Set a breakpoint on CTFontLogSuboptimalRequest to debug.
2013-11-07 22:42:54.519 node-webkit Helper EH[78148:507] CoreText performance note: Client called CTFontCreateWithName() using name "Times Roman" and got font with PostScript name "Times-Roman". For best performance, only use PostScript names when calling this API.
[78145:1107/224258:INFO:CONSOLE(0)] "'KeyboardEvent.keyLocation'' is deprecated. Please use 'KeyboardEvent.location' instead.", source:  (0)

2 个答案:

答案 0 :(得分:1)

我尝试了很多变体,包括YouTube推荐的iFrame嵌入方法,但根据https://developers.google.com/youtube/player_parameters的文档,您无法完全摆脱YouTube链接。

您可以做的最好的事情是隐藏大部分控件等,但在播放期间,用户仍然可以选择点击YouTube徽标并离开您的网站。

答案 1 :(得分:1)

如果您在node-webkit应用中使用WebChimera,则可以使用它播放youtube链接并将所需的按钮添加到工具栏(只需要很少的编程),然后将按钮单击事件发送到JS告诉它该怎么做。 (在您的情况下,使用默认浏览器打开YouTube链接)

WebChimera Player移植到Node-Webkit(在应用程序中嵌入了WebChimera插件): https://github.com/jaruba/WebChimeraPlayerNW

Download Link for Windows

对于Mac,Readme.md中有逐步说明。