一个简单的node-webkit客户端

公司要做一个PC客户端,用于做视频直播,基于webkit内核的,因为我之前的delphi从业经验,客户端的开发落到了我这里,开始使用delphi xe6的控件:下载地址:http://www.400gb.com/file/64222558

但是经过测试,没有内置flashplayer插件,而且是精简版的,稳定性好像不太好,后来去github下了完整的插件:https://github.com/hgourvest/dcef3,

因为没有找到加载内置flashplayer的方法,又找到国内大牛开发的组件:http://www.bccsafe.com/,

参照他的教程终于可以基于webkit和内置flashplayer播放器的客户端了,但是稳定性实在太差了,flashplayer经常卡机,

导致客户端崩溃,辗转反侧,试了很度delphi版本的dcef3,稳定性还是没有保障,最终不得不放弃delphi开发,然后找到了网易的开发工具:http://hex.youdao.com/zh-cn/index.html

该工具完全可以胜任,但是打包起来感觉有点麻烦,可能是没有找到正确的打包方法,然后寻藤摸瓜找到了node-webkit:https://github.com/nwjs,

教程:https://github.com/nwjs/nw.js/wiki

相关教程:

http://www.tuicool.com/articles/VfMFziM

http://damoqiongqiu.iteye.com/blog/2010720

flash插件:http://pan.baidu.com/share/link?shareid=1272940939&uk=336267035#path=%252F

但是在监听windown的isfullscreen上有问题,在window双击拖动条的时候,只好改用判断div的class属性来确定:

max.addEventListener('click', function(evt){
if($(max).hasClass('max')){
win.restore();
}else if($(max).hasClass('normal')){
win.maximize();
}
});

 

同事要监听:maximize事件

后面要做shell实现在iframe里面点击一个页面,然后使用系统默认浏览器打开,shell的脚本是:

function openUrl(url){
if(gui == undefined){
var gui = require('nw.gui');
}

var shell = gui.Shell;
shell.openExternal(url);
}

 

这个时候就涉及到iframe调用主窗口的函数了,可以使用这个种方法解决:

<iframe src="http://test/index.php" nwfaketop onload="this.contentWindow.openUrl = openUrl">

</iframe>

细节:

禁用窗口拖拽:

<body style="overflow-y: hidden" "draggable"="false" oncontextmenu="return false" onselectstart="return false" ondragstart="return false" onbeforecopy="return false" oncopy=document.selection.empty() onselect=document.selection.empty()>

 

posted @ 2015-10-26 16:53  phpnaruto  阅读(1310)  评论(0)    收藏  举报