1 Star 0 Fork 27

永远的java/binDoubanFM

forked from wubin.in/binDoubanFM 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.aau 22.86 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885
/*
***************************
* *
* 豆瓣FM 第三方客户端 *
* *
* by 武斌 http://wubin.in *
* *
***************************
*/
_app = "斌哥豆瓣FM桌面版";
_blank = "~ 优雅地欣赏音乐 ~";
_ver = "1.0.2 build 20140112";
import win.ui;
import win.ui.atom;
import win.ui.menu;
import win.timer;
import win.clip;
import win.util.popup2;
import win.util.tray;
import web.layout;
import web.layout.behavior.windowCommand;
import web.layout.behavior.tabs;
import web.layout.behavior.dropdown;
import com;
import process;
import binFM;
import binFM.aero;
import binFM.auto;
import binFM.db;
import binFM.douban;
import binFM.download;
import binFM.hotkey;
import binFM.init;
import binFM.lrc;
import binFM.search;
import binFM.string;
import binFM.to;
import binFM.ui;
/*
*用于自动更新的临时文件
* -- 参数为 -update "路径"
*/
var cmd = _CMDLINE;
if(cmd && string.trim(cmd)!="") {
if(string.indexOf(cmd,'-update \"')==1) {
binFM.toUpdate(cmd);
win.quitMessage();
return true;
}
}
if(io.exist(io._exedir ++ "doubanFM_lastest.exe") && !io.exist(io._exedir ++ "doubanFM_lastest.exe.dowload")) {
win.msgbox(_app++'最新版已下载完毕!\r\n\r\n请您手动删除' ++ io._exefile ++ ',\r\n并将doubanFM_lastest.exe重命名为' ++ io._exefile ++ '。',_app);
}
if(io._exefile=="doubanFM_lastest.exe") {
win.msgbox(_app++'最新版已下载完毕!\r\n\r\n请将doubanFM_lastest.exe重命名为' ++ _app ++ '.exe,\r\n以便下次更新。',_app);
return false;
}
mainForm = win.form(
bgcolor=0;
bottom=492;
right=312;
border="none";
text=_app
)
wbLayout = web.layout(mainForm);
wbLayout.go("/res/index.html");
if(_STUDIO_INVOKED) {
io.open();
import web.layout.debug;
wbLayout.attachEventHandler( web.layout.debug );
}
mainForm.transparent(true);
import fsys;
_data = fsys.getSpecial(0x1a /*_CSIDL_APPDATA*/) ++ "\doubanFM_wubin";
// win7 C:\Users\administrator\AppData\Roaming
// xp C:\Document and Settings\administrator\Application Data
binFM.ui.splash("update");
binFM.init.varAndConst();
/* ======================================================= */
/* HTMLayout 控件部分 ==================================== */
/* ======================================================= */
/*
* 响应菜单点击事件
* -- 包括 标题栏上的菜单 专辑封面右键菜单 曲目列表右键菜单
*/
wbLayout.onMenuItemClick = {
// =============================
// 退出程序菜单
// =============================-;
exit = function (ltTarget,ltEle,reason,behaviorParams) {
mainForm.close();
}
// =============================
// 我的豆瓣主页菜单
// =============================
myDouban = function (ltTarget,ltEle,reason,behaviorParams) {
if(login) process.execute("http://www.douban.com/people/" ++ userId ++ "/");
}
// =============================
// 转到红心兆赫菜单
// =============================
toFavChannel = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.to.favChannel();
}
// =============================
// 显示收听历史菜单
// =============================
toHistory2 = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.ui.showHistory();
}
// =============================
// 退出登录菜单
// =============================
toLogout = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.to.logout();
}
// =============================
// 下载歌曲菜单
// =============================
saveMusic = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.search.download("douban");
}
saveMusic_2 = function (ltTarget,ltEle,reason,behaviorParams) {
var sid,title,url;
sid = binFM.ui.$("#listbox").value;
binFM.search.download("douban",sid);
}
// =============================
// 查看下载任务菜单
// =============================
openDownloads = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.ui.showDownloads();
}
// =============================
// 保存歌词菜单
// =============================
saveLrc_copy = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.lrc.save("copy");
}
saveLrc_copytext = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.lrc.save("copyText");
}
saveLrc_file = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.lrc.save("file");
}
// =============================
// 复制歌曲名称
// =============================
copyTitle = function (ltTarget,ltEle,reason,behaviorParams) {
var nowPlaying = binFM.song();
if(nowPlaying) win.clip.write(nowPlaying["title"]);
}
copyTitle_2 = function (ltTarget,ltEle,reason,behaviorParams) {
var sid = binFM.ui.$("#listbox").value;
if(sid) var title = binFM.song(sid)["title"];
if(title && title!="") win.clip.write(title);
}
// =============================
// 百度搜索
// =============================
baidu = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.search.music("baidu");
}
baidu_2 = function (ltTarget,ltEle,reason,behaviorParams) {
var sid = binFM.ui.$("#listbox").value;
binFM.search.music("baidu",sid);
}
baidu_img = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.search.image("baidu");
}
baidu_img2 = function (ltTarget,ltEle,reason,behaviorParams) {
var sid = binFM.ui.$("#listbox").value;
binFM.search.image("baidu",sid);
}
// =============================
// 转到豆瓣专辑介绍
// =============================
toDoubanAlbum = function (ltTarget,ltEle,reason,behaviorParams) {
var sid = binFM.ui.$("#listbox").value;
if(sid) {
var albumUrl = binFM.song(sid)["album"];
if(albumUrl) process.execute("http://music.douban.com" ++ albumUrl);
}
}
// =============================
// 转到艺术家简介
// =============================
musician = function (ltTarget,ltEle,reason,behaviorParams) {
var nowPlaying = binFM.song();
if(nowPlaying) {
var artist_id;
if(nowPlaying["artist_id"]) artist_id = nowPlaying["artist_id"];
else artist_id = binFM.douban.getArtistId(nowPlaying["sid"]);
if(artist_id) process.execute("http://music.douban.com/musician/" ++ artist_id ++ "/");
}
}
// =============================
// 删除歌曲菜单
// =============================
toDel_2 = function (ltTarget,ltEle,reason,behaviorParams) {
var sid = binFM.ui.$("#listbox").value;
if(sid) {
// 在播放列表中删除当前项
binFM.to.del_list(sid);
}
}
// =============================
// 自动加心 / 屏蔽菜单
// =============================
likeByArtist = function (ltTarget,ltEle,reason,behaviorParams) {
if(isLikeByArtist==1 || (isLikeByArtist==0 && autoFormShown)) binFM.auto.addLikeArtist();
else if(isLikeByArtist==0 && !autoFormShown) binFM.ui.showAutoLikeDel();
}
likeByAlbum = function (ltTarget,ltEle,reason,behaviorParams) {
if(isLikeByAlbum==1 || (isLikeByAlbum==0 && autoFormShown)) binFM.auto.addLikeAlbum();
else if(isLikeByAlbum==0 && !autoFormShown) binFM.ui.showAutoLikeDel();
}
delByArtist = function (ltTarget,ltEle,reason,behaviorParams) {
if(isDelByArtist==1 || (isDelByArtist==0 && autoFormShown)) binFM.auto.addDelArtist();
else if(isDelByArtist==0 && !autoFormShown) binFM.ui.showAutoLikeDel();
}
delByAlbum = function (ltTarget,ltEle,reason,behaviorParams) {
if(isDelByAlbum==1 || (isDelByAlbum==0 && autoFormShown)) binFM.auto.addDelAlbum();
else if(isDelByAlbum==0 && !autoFormShown) binFM.ui.showAutoLikeDel();
}
delEnglish = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.auto.addDelEnglish("menu");
}
// =============================
// 显示 / 隐藏 歌词菜单
// =============================
displayLrc = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.ui.showLrc();
}
// =============================
// 开启 / 关闭 Aero效果
// =============================
doAero = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.aero.toggle();
}
// =============================
// 设置热键菜单
// =============================
showHotkeySetups = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.ui.showHotkeySetups();
}
// =============================
// 设置歌词字体菜单
// =============================
showFontsSetups = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.ui.showFontsSetups();
}
// =============================
// 是否随即排列歌曲
// =============================
randomSongs = function (ltTarget,ltEle,reason,behaviorParams) {
if(randomSongs) {
randomSongs = false;
binFM.ui.menuToggle("#isRandomSongs","off");
}
else {
randomSongs = true;
binFM.ui.menuToggle("#isRandomSongs","on");
}
}
// =============================
// 设置自动加红心/屏蔽菜单
// =============================
showAutoLikeDel = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.ui.showAutoLikeDel();
}
// =============================
// 关于菜单
// =============================
showAbout = function (ltTarget,ltEle,reason,behaviorParams) {
if(!aboutForm) aboutForm = mainForm.loadForm("\forms\aboutForm.aau",mainForm);
aboutForm.show();
win.setForeground(aboutForm.hwnd);
}
// =============================
// 软件主页菜单
// =============================
home = function (ltTarget,ltEle,reason,behaviorParams) {
process.execute("http://wubin.in/doubanFM.html?app");
}
// =============================
// 转到豆瓣fm官方网站菜单
// =============================
doubanFM = function (ltTarget,ltEle,reason,behaviorParams) {
process.execute("http://douban.fm");
}
// =============================
// --
// =============================
default = function (ltTarget,ltEle,reason,behaviorParams) {
win.msgboxTimeout("此功能尚未完成...",_app,3000);
}
}
/*
* 响应按钮点击事件
*/
wbLayout.onButtonClick = {
// =============================
// 登录按钮
// =============================
showLoginForm = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.to.login();
}
// =============================
// 频道选择按钮 - 主面板右滑
// =============================
channels = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.ui.slideRight();
}
// =============================
// 频道按钮
// =============================
channel = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.to.channel(ltTarget.cId);
}
// =============================
// 加歌按钮
// =============================
toAddMusic = function(ltTarget,ltEle,reason,behaviorParams){
if(binFM.douban.getSongs(channelId,false)){
if(wmp.playState==1 || wmp.playState==2 ) binFM.to.play("play");
else wmp.controls.play();
}
else return false;
}
listToAdd = function(ltTarget,ltEle,reason,behaviorParams) {
if(binFM.douban.getSongs(channelId,false)){
if(wmp.playState==1 || wmp.playState==2 ) binFM.to.play("play");
else wmp.controls.play();
}
else return false;
}
// =============================
// 专辑封面 转到专辑介绍
// =============================
album_cover = function(ltTarget,ltEle,reason,behaviorParams){
binFM.ui.showAlbum();
}
song_title = function(ltTarget,ltEle,reason,behaviorParams){
binFM.ui.showAlbum();
}
// =============================
// 红心按钮
// =============================
like_liked = function(ltTarget,ltEle,reason,behaviorParams){
binFM.to.like();
}
// =============================
// 下一首按钮
// =============================
toNext = function(ltTarget,ltEle,reason,behaviorParams){
binFM.to.next();
}
// =============================
// 删除歌曲按钮
// =============================
toDel = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.to.del();
}
// =============================
// 播放/暂停按钮
// =============================
pause_play = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.to.play();
}
// =============================
// 显示收听历史按钮
// =============================
toHistory = function(ltTarget,ltEle,reason,behaviorParams){
binFM.ui.showHistory();
}
// =============================
// 播放进度滑块
// =============================
postBar_hslider = function (ltTarget,ltEle,reason,behaviorParams) {
if(wmp.currentMedia) {
if(ltTarget.value == 0) ltTarget.value = 1;
var postBarValue = math.round(ltTarget.value / 3);
binFM.ui.css("#posBar","width",ltTarget.value);
wmp.controls.currentPosition = wmp.currentMedia.duration * postBarValue / 100;
posChanged = true;
lrc_last = 1;
}
}
// =============================
// 显示/隐藏歌词按钮
// =============================
showLrc = function (ltTarget,ltEle,reason,behaviorParams) {
binFM.ui.showLrc();
}
// =============================
// 静音按钮
// =============================
toMute = function (ltTarget,ltEle,reason,behaviorParams) {
if(!wmp.settings.mute && wmp.settings.volume>0) {
muteFromMain = true; // 用户在主窗体设置的静音
binFM.ui.volume("mute");
wmp.settings.mute = true;
}
else{
muteFromMain = false;
binFM.ui.volume("unmute");
wmp.settings.volume = volume;
wmp.settings.mute = false;
}
}
// =============================
// 武斌主页按钮
// =============================
wubin = function (ltTarget,ltEle,reason,behaviorParams) {
process.execute("http://wubin.in/doubanFM.html?app");
}
// =============================
// 退出程序按钮
// =============================
main_close = function (ltTarget,ltEle,reason,behaviorParams) {
mainForm.close();
}
}
/*
* 曲目列表框事件
*/
wbLayout.onSelectStateChanged = {
listbox = function (ltTarget,ltEle,reason,behaviorParams) {
// 获取选中曲目的信息
var selectedIndex;
var selectedSid = ltTarget.value;
if(!tonumber(selectedSid)) return false;
var selectedItem = binFM.song(selectedSid);
if(selectedItem) selectedIndex = selectedItem["i"] - 1;
// 获取当前曲目信息
var nowPlaying = binFM.song();
if(!nowPlaying) return false;
if(selectedSid != nowPlaying["sid"]) {
// 标记选中曲目
binFM.ui.playlistItem(nowPlaying["sid"],selectedSid);
// 播放选中曲目
try{
wmp.controls.playItem(wmp.currentPlaylist.getItem(selectedIndex));
}
// 生成发送至豆瓣的跳过曲目报告
var sid = nowPlaying["sid"];
binFM.douban.historyString("skip");
//io.print(history);
}
}
}
/*
* 滑块滑动事件
*/
wbLayout.onButtonStateChanged = {
// =============================
// 播放进度滑块
// =============================
postBar_hslider = function (ltTarget,ltEle,reason,behaviorParams) {
posChanged = false;
lrc_last = 1; // 重新从歌词数组中搜索歌词行来显示
}
// =============================
// 音量控制滑块
// =============================
volumeBar_hslider = function (ltTarget,ltEle,reason,behaviorParams) {
var volume_ = math.round(ltTarget.value * 1.724); // 100 / 58 = 1.724
if(volume_!=0) {
if(volume!=volume_){
volume = volume_;
wmp.settings.volume = volume;
}
if(wmp.settings.mute) wmp.settings.mute = false;
}
else {
binFM.ui.volume("mute");
wmp.settings.mute = true;
}
binFM.ui.volume(volume);
}
}
/*
* 选项卡事件: 专辑封面 播放列表
*/
wbLayout.onElementExpanded = {
album_area = function (ltTarget,ltEle,reason) {
binFM.ui.hide("#toAddMusic",,400);
}
playList = function (ltTarget,ltEle,reason) {
binFM.ui.hide("#song-loading");
binFM.ui.show("#toAddMusic",,400);
var nowPlaying = binFM.song();
if(nowPlaying) binFM.ui.$("#listbox").value = nowPlaying["sid"];
}
}
/*
* 托盘右键菜单
*/
mainForm.popmenu = win.ui.popmenu(mainForm);
mainForm.popmenu.addTable({
/*
{_app;function(id){
process.execute("http://wubin.in/doubanFM.html?app");
}};
{}
*/
{"专辑";{
{"查看专辑介绍";function(id){
binFM.ui.showAlbum();
}};
{"转到专辑详情";function(id){
var nowPlaying = binFM.song();
if(nowPlaying) {
var artist_id;
if(nowPlaying["artist_id"]) artist_id = nowPlaying["artist_id"];
else artist_id = binFM.douban.getArtistId(nowPlaying["sid"]);
io.print("artistId",artist_id);
if(artist_id) process.execute("http://music.douban.com/musician/" ++ artist_id ++ "/");
}
}};
}};
{"艺术家";{
{"转到艺术家详情";function(id){
var nowPlaying = binFM.song();
if(nowPlaying) {
var artist_id = nowPlaying["artist_id"];
if(artist_id) process.execute("http://music.douban.com/musician/" ++ artist_id ++ "/"); }
}};
{"百度艺术家图片";function(id){
binFM.search.image("baidu",sid);
}};
}};
{"曲目";{
{"百度搜索曲目";function(id){
binFM.search.music("baidu");
}};
{"复制曲目标题";function(id){
var nowPlaying = binFM.song();
if(nowPlaying) win.clip.write(nowPlaying["title"]);
}};
{/*分隔线*/};
{"另存为";function(id){
binFM.search.download("douban");
}};
}};
{/*分隔线*/};
{"保存歌词";{
{"复制到剪贴板";function(id){
binFM.lrc.save("copy");
}};
{"仅复制歌词文本";function(id){
binFM.lrc.save("copyText");
}};
{/*分割线*/};
{"另存为lrc文件";function(id){
binFM.lrc.save("file");
}};
}};
{"设置歌词字体";function(id){
binFM.ui.showFontsSetups();
}};
{"显示 / 隐藏歌词";function(id){
binFM.ui.showLrc();
}};
{/*分割线*/}
{"加红心(不取消)";function(id){
binFM.to.like(true);
}};
{"不再听";function(id){
binFM.to.del();
}};
{"下一首";function(id){
binFM.to.next();
}};
{"播放 / 暂停";function(id){
binFM.to.play();
}};
{/*分隔线*/};
{"显示主面板";function(id){
win.setForeground(mainForm.hwnd);
}};
{"退出豆瓣FM";function(id){
mainForm.close();
}};
});
/*
* 窗体事件
*/
RegisterWindowMessage := ::User32.api( "RegisterWindowMessageA", "Long(String lpString)");
var msgTaskbarRestart = RegisterWindowMessage("taskbarcreated");
mainForm.wndproc = {
[0x6/*_WM_ACTIVATE*/] = function (hwnd, message, wParam, lParam) {
if ( ::HIWORD(wParam) !== 0 ){
// 最小化
mainFormActive = false;
mainForm.show(false);
if(!tray) {
tray = win.util.tray(mainForm);
tray.pop('单击打开/关闭悬浮窗口\r\n右键打开菜单\r\n双击打开主面板',.._app);
tray.message = 0x400+9981/*_WM_TRAYMESSAGE*/ //设置托盘图标回调消息
}
binFM.ui.showMiniForm();
return true;//阻击默认消息传递,取消最小化过程
}
else
// 正常
mainFormActive = true;
select ( ::LOWORD(wParam) ) {
case 0x1 {/*_WA_ACTIVE*/ // 被激活
mainFormActive = true;
if(popupForm) popupForm.close();
popupShowing = false;
}
case 0x2 { /*_WA_CLICKACTIVE*/ // 被鼠标点击激活
mainFormActive = true;
if(popupForm) popupForm.close();
if(miniForm) miniForm.close();
popupShowing = false;
win.setForeground(mainForm.hwnd);
if(albumForm && albumFormShown) binFM.ui.showAlbum();
}
case 0x0 { /*_WA_INACTIVE*/ // 失去焦点
mainFormActive = false;
}
}
}
[msgTaskbarRestart] = function(hwnd,message,wParam,lParam) { // 当重建任务栏时
if(tray) {
win.util.tray.Shell_NotifyIcon(0x2/*_NIM_DELETE*/,tray.m_tnd);
win.util.tray.Shell_NotifyIcon(0x0/*_NIM_ADD*/,tray.m_tnd);
}
}
[0x400+9981/*_WM_TRAYMESSAGE*/] = function(hwnd,message,wParam,lParam) {
if(lParam==0x203/*_WM_LBUTTONDBLCLK)*/) { // 左键双击
if(miniShown && miniForm) {
miniForm.close();
miniShown = false;
}
win.setForeground(mainForm.hwnd);
return;
}
if(lParam==0x202/*_WM_LBUTTONUP*/) { // 左键单击
if(miniShown && miniForm) {
miniForm.close();
miniShown = false;
}
else binFM.ui.showMiniForm();
return;
}
if(lParam==0x205/*_WM_RBUTTONUP*/) { // 右键单击
import mouse;
var x,y = mouse.getPos();
win.setForeground(mainForm.hwnd);
mainForm.popmenu.popup(x,y,true);
}
}
[0x10/*_WM_CLOSE*/] = function(hwnd,message,wParam,lParam) {
// 当窗体关闭时
binFM.quit();
}
}
/*
* 原子窗体
*/
if(io._exefile!="doubanFM_update_"++_ver) {
var atom,hwnd/*冲突窗口的句柄,该函数会自动激活此窗口*/ = mainForm.atom("14959179-09B5-4B65-9291-F62090993C40");
if(!atom){
/*为窗口设置原子值可以避免一个程序重复运行多个实例*/
win.quitMessage();
return;
}
else {
mainForm.show();
mainFormActive = true;
win.delay(100);
}
}
/* ======================================================= */
/* 播放状态部分 ========================================== */
/* ======================================================= */
/*
* 播放进度计时器
*/
timer = win.timer( mainForm );
binFM.ui.position(,,"init");
..muteFlag = false;
timer.onTimer = function(hwnd,msg,id,tick){
if(!wmp.currentMedia) return false;
var nowPlaying = binFM.song();
// 显示播放进度
if(wmp.controls.currentPosition && wmp.currentMedia.duration) binFM.ui.position(wmp.controls.currentPosition,wmp.currentMedia.duration);
// 显示歌词
if(nowPlaying) binFM.lrc.show(nowPlaying["sid"]);
// 当歌曲播放完时
if(wmp.currentMedia.duration>0 && wmp.controls.currentPosition>0 && (wmp.currentMedia.duration - wmp.controls.currentPosition <= 1) && !endSended) {
if(nowPlaying) {
binFM.ui.showNext(nowPlaying);
binFM.douban.sendEnded(nowPlaying["sid"]);
binFM.db.recordSong(nowPlaying["sid"],0);
}
gettingLrc = false;
lrcGot = false;
endSended = true;
}
// 监控win7混音器设置的音量
if(volume!=wmp.settings.volume) {
binFM.ui.volume(wmp.settings.volume);
volume = wmp.settings.volume;
}
if(muteFlag!=wmp.settings.mute) {
if(wmp.settings.mute) binFM.ui.volume("mute");
else binFM.ui.volume("unmute");
if(!muteFromMain) {
volume = 20;
wmp.settings.volume = 20;
}
muteFlag = wmp.settings.mute;
}
}
/*
* WMPlayer事件
*/
// 注册 windows media player
try {
wmp = com.CreateObject("WMPlayer.OCX");
}
if(!wmp) {
win.msgboxTimeout('未安装Windows Media Player,\r\n请检查您的系统组件。',_app,5000);
win.quitMessage();
}
// WMPlayer状态
wmpEvent = {
PlayStateChange = function(a){
io.print("wmp状态",a);
var nowPlaying = binFM.song();
if(!nowPlaying) return false;
if(a==9) { // 准备播放
// 初始化下一首歌的播放
gettingLrc = false;
lrcGot = false;
lrc_list = {};
line1=""; line2="";
autoLikeChecked = false;
io.print('\r\n=========================\r\n');
return;
}
if(a==6) { // 正在缓冲
binFM.ui.showCurrent(nowPlaying,"buffering");
return;
}
if(a==3) { // 正在播放
timer.enable();
// 首次隐藏splash层
mainForm.setTimeout(binFM.ui.splash,200,"hide");
// 显示当前曲目信息、加红心状态、右下角弹窗 并 在播放列表中标注正在播放的歌曲
binFM.ui.showCurrent(nowPlaying);
// 获取并显示歌词
binFM.lrc.get(nowPlaying["title"], nowPlaying["artist"], nowPlaying["sid"]);
lrc_last = 1;
// 是否需要自动加红心
binFM.auto.checkLike(true);
// 播放到列表尽头时获取歌曲
var currentIndex = nowPlaying["i"];
if(currentIndex == binFM.ui.$("#listbox").children()-2) binFM.douban.getSongs(channelId,false);
// 准备报告给豆瓣的信息
endSended = false;
binFM.douban.historyString(nowPlaying["sid"],"play");
return;
}
if(a==1 || a==2) { // 暂停或停止
timer.disable();
return;
}
}
}
// 注册WMPLayer事件
try{
wmpEvent = com.Connect(wmp, wmpEvent);
}
if(!wmpEvent) {
win.quitMessage();
}
/* ======================================================= */
/* 初始化部分 ============================================ */
/* ======================================================= */
// 检查数据库
binFM.db.checkDB();
// 获取并应用用户配置
binFM.init.profile();
// 开始播放
if(binFM.douban.getSongs(channelId,true)) {
wmp.controls.play();
}
// 注册热键
binFM.hotkey.read("db");
binFM.hotkey.reg();
// 检查更新
binFM.checkUpdate();
win.loopMessage();
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jelly-8090/binDoubanFM.git
[email protected]:jelly-8090/binDoubanFM.git
jelly-8090
binDoubanFM
binDoubanFM
master

搜索帮助