Merge pull request #55 from kPherox/fix-nowplaying-for-asar-packed

Fix nowplaying for asar packed
This commit is contained in:
Cutls 2019-04-14 01:41:30 +09:00 committed by GitHub
commit 53f880ab97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 10 deletions

View File

@ -129,6 +129,10 @@ function nowplaying(mode){
ipc.send('itunes', "");
ipc.once('itunes-np', function (event, arg) {
if (arg.cmd) {
console.error(arg);
return;
}
console.log(arg);
var content=localStorage.getItem("np-temp");
if(!content || content=="" || content=="null"){
@ -142,8 +146,8 @@ function nowplaying(mode){
media(arg.path,"image/png","new");
}
}else if(platform=="darwin"){
if(flag && arg.artworks[0]){
ipc.send('bmp-image', [arg.artworks[0].path,0]);
if(flag && arg.existsArtwork){
media(arg.artworks[0].data,"image/png","new");
}
}
var regExp = new RegExp("{song}", "g");

View File

@ -4,7 +4,7 @@ function np(mainWindow){
const app = electron.app;
const fs = require("fs");
var ipc = electron.ipcMain;
ipc.on('itunes', (e, args) => {
ipc.on('itunes', async (e, args) => {
//Verified on Windows
console.log("Access");
if(args[0]=="set"){
@ -25,13 +25,15 @@ function np(mainWindow){
var platform=process.platform;
var bit=process.arch;
if(platform=="darwin"){
const nowplaying = require("itunes-nowplaying-mac")
nowplaying.getRawData().then(function (value) {
try {
const nowplaying = require("itunes-nowplaying-mac");
const value = await nowplaying.getRawData();
mainWindow.webContents.send('itunes-np', value);
}).catch(function (error) {
// 非同期処理失敗。呼ばれない
console.log(error);
});
} catch (error) {
// エラーを返す
console.error(error);
mainWindow.webContents.send('itunes-np', error);
}
}else{
var {NowPlaying,PlayerName} = require("nowplaying-node");
var nppath=join(app.getPath("userData"), "nowplaying");

View File

@ -49,12 +49,15 @@
},
"optionalDependencies": {
"nowplaying-node": "^0.1.3",
"itunes-nowplaying-mac": "git+https://github.com/rinsuki/itunes-nowplaying-mac#pull/1/head",
"itunes-nowplaying-mac": "git+https://github.com/rinsuki/itunes-nowplaying-mac#pull/4/head",
"font-manager": "^0.3.0"
},
"build": {
"productName": "TheDesk",
"appId": "top.thedesk",
"asarUnpack": [
"node_modules/itunes-nowplaying-mac"
],
"directories": {
"output": "../build"
},