2019-05-19 17:39:30 +10:00
|
|
|
function np(mainWindow) {
|
2020-01-12 03:23:07 +11:00
|
|
|
const electron = require('electron')
|
|
|
|
const join = require('path').join
|
|
|
|
const app = electron.app
|
2020-01-13 00:49:52 +11:00
|
|
|
const fs = require('fs')
|
|
|
|
const fpath = join(app.getPath('userData'), 'npexec')
|
|
|
|
const npExec = fs.readFileSync(fpath, 'utf8')
|
2020-01-12 03:23:07 +11:00
|
|
|
const ipc = electron.ipcMain
|
2020-01-13 00:49:52 +11:00
|
|
|
|
2020-01-12 03:23:07 +11:00
|
|
|
const { exec } = require('child_process')
|
|
|
|
ipc.on('itunes', async (e, args) => {
|
|
|
|
console.log('Access')
|
|
|
|
if (args[0] == 'set') {
|
|
|
|
} else {
|
|
|
|
var platform = process.platform
|
|
|
|
var bit = process.arch
|
|
|
|
if (platform == 'darwin') {
|
|
|
|
try {
|
|
|
|
const nowplaying = require('itunes-nowplaying-mac')
|
|
|
|
let value = await nowplaying()
|
2020-01-12 22:42:23 +11:00
|
|
|
const artwork = await nowplaying.getThumbnailBuffer(value.databaseID)
|
|
|
|
const base64 = artwork.toString('base64')
|
|
|
|
value.artwork = base64
|
|
|
|
e.sender.webContents.send('itunes-np', value)
|
2020-01-12 03:23:07 +11:00
|
|
|
} catch (error) {
|
|
|
|
// エラーを返す
|
|
|
|
console.error(error)
|
2020-01-13 00:49:52 +11:00
|
|
|
e.sender.webContents.send('itunes-np', error)
|
2020-01-12 03:23:07 +11:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
}
|
2020-01-13 00:49:52 +11:00
|
|
|
})
|
|
|
|
|
2019-04-03 14:59:29 +11:00
|
|
|
}
|
2020-01-12 03:23:07 +11:00
|
|
|
exports.TheDeskNowPlaying = np
|