[HTA 源码] 豆瓣FM网页播放器,写给喜欢这个网页播放器的人 by yu2n
在线预览:http://douban.fm/radio
源码下载:
2015.01.08 更新:网络不通时,自动尝试重新连接(如将播放器加入系统启动项运行时,ADSL可能还未准备好。)。- <html>
- <html>
- <hta:Application ID="douban_fm" ApplicationName="douban_fm" Title="豆瓣FM"
- border="thin" borderstyle="normal" caption="yes" icon="http://douban.fm/favicon.ico"
- maximizebutton="no" minimizebutton="yes" closebutton="yes" showintaskbar="yes" singleinstance="yes"
- sysmenu="yes" version="1.0" windowstate="minmize"
- />
- <head>
- <title>豆瓣FM</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <script language=JavaScript type="text/javascript">
- // 在窗口显示前更改窗口大小
- while (true) {try {var w=420,h=0; window.resizeTo(w, h); window.moveTo((window.screen.width - w) / 2, (window.screen.height - h) / 2); break; } catch (e) {continue;} }
- // 屏蔽错误
- window.onerror=function(){return true;}
- // 在标题栏显示载入中
- var strTitle = document.title;
- document.title = strTitle + " - 载入中 ... ";
- // 判断网络连接
- if (!ping("douban.fm")) {
- document.title = strTitle + " - 网络故障,请检查网络连接 ...";
- setInterval("document.execCommand('Refresh');douban_fm.icon='http://douban.fm/favicon.ico';", 3000);
- };
- // 载入框架后执行
- function douban_loading()
- {
- win_resize(420,186);
- document.title = strTitle;
- }
- // 修改窗口内页面的大小(非窗口)
- function win_resize(w,h)
- {
- var winWidth, winHeight;
- var w2=w, h2=h;
- for (var i = 0; i < window.screen.width; i++)
- {
- //获取窗口宽度
- if (window.innerWidth)
- winWidth = window.innerWidth;
- else if ((document.body) && (document.body.clientWidth))
- winWidth = document.body.clientWidth;
- //获取窗口高度
- if (window.innerHeight)
- winHeight = window.innerHeight;
- else if ((document.body) && (document.body.clientHeight))
- winHeight = document.body.clientHeight;
- //通过深入Document内部对body进行检测,获取窗口大小
- if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth)
- {
- winHeight = document.documentElement.clientHeight;
- winWidth = document.documentElement.clientWidth;
- }
-
- // 小于指定大小时,调大窗口
- if (winWidth <= w)(w2 = w + i);
- if (winHeight <= h)(h2 = h + i);
- if ((winWidth >= w) && (winHeight >= h)){break;}
- window.resizeTo(w2, h2);
- window.moveTo((window.screen.width - w2) / 2, (window.screen.height - h2) / 2);
- }
- }
- // Ping
- function ping(host){
- var oWmic = GetObject("winmgmts:{impersonationLevel=impersonate}"
- ).ExecQuery("select * from Win32_PingStatus where address = '" + host + "'")
- var oEnum = new Enumerator(oWmic); for (; !oEnum.atEnd(); oEnum.moveNext()) {
- if (oEnum.item().ResponseTime != null && oEnum.item().ResponseTime >= 0) return(true);
- }; return(false);
- }
- </script>
- <style type="text/css">
- html, body { margin: 0px; padding: 0px; }
- .douban_fm_iframe {
- height: 100%; width: 100%;
- margin: 0px; padding: 0px;
- overflow: visible;
- }
- </style>
- </head>
- <body>
- <iframe class="douban_fm_iframe" src="http://douban.fm/radio" scrolling="NO" onload="douban_loading();">
- </body>
- </html>
复制代码 |