4
votes

i'm embedding youtube videos in a node-webkit frameless app, Whenever the youtube link inside the video is clicked, the expected behavior is to open the url in the default browser, but what it does is to create a new node-webkit frameless window that is on top of my app. iv'e tried overriding window.open but this does not help as flash is probably uses some other api to launch a new window, what i'm looking for is a way to either disable new windows altogether or, to be able to intercept whenever a new window is opened and to redirect the url to the default browser. I looked trough the api and it seems that javascript is not exposed to the browser process which has all the window instances.

Any ideas on how to solve this issue?

Edit: Ok so there is a way to disable flash calling navigateToURL it is a param that you add to your : <param name="allowNetworking" value="internal"/> while not ideal this helps with the UX. Source: http://livedocs.adobe.com/flex/3/html/help.html?content=wrapper_13.html

Second Edit: Another bug I discovered is that the second popup crashes node-webkit altogether, here is what the console does not output anything useful:

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
Could you by any chance post a small example of the HTML page in question? I've done something almost like this for an application that had to open links in the default browser as well and ended up attaching an eventListener to the window. - Ewald
Oh man, I can't even get it to run, I get a "plugin not found" error, on Windows. Let me fix that plugin issue on the machine first, I never use Flash. - Ewald
@Ewald Oh yeah forgot about that, there are two ways to go around solving this, first is to just install flash player from here: get.adobe.com/flashplayer/download/… Or find this dll somewhere: NPSWF32_11_9_900_117.dll and put it under ./plugins - currently node-webkit does not have the License to redistribute flash by itself like chrome does. - Leon Fedotov
Thank you, I've already done that :) I am a bit unused to Windows, I prefer Linux, but I have to learn. I'm working on a solution for you though, I have made a bit of progress. - Ewald

2 Answers

1
votes

I've tried many variations, including the recommend iFrame embedding method of YouTube, but according to the documentation at https://developers.google.com/youtube/player_parameters you can not completely get rid of the YouTube link.

The best you can do is to hide most of the controls etc., but during play, there will still be the option for the user to click on the YouTube logo and navigate away from your site.

1
votes

If you use WebChimera in your node-webkit app, you can play youtube links with it and add what buttons you want to the toolbar (with little programming involved), then send the button click event to JS to tell it what to do. (in your case, open the youtube link with the default browser)

WebChimera Player ported to Node-Webkit (with WebChimera Plugin embedded in the app): https://github.com/jaruba/WebChimeraPlayerNW

Download Link for Windows

For Mac there are step-by-step instructions in Readme.md.