got a lot working
This commit is contained in:
1 parent
e0fcf3326e
commit
a7bd278b4a
11 files changed
+166
-36
No files matched your search
+66
-6
@@ -1,16 +1,25 @@
|
||||
const { app, BrowserWindow } = require('electron');
|
||||
// const { initialize, enable } = require('@electron/remote/main');
|
||||
const path = require('node:path');
|
||||
// const { app, BrowserWindow, ipcMain } = require('electron');
|
||||
// const { fromUrl } = require('id3js');
|
||||
// const path = require('node:path');
|
||||
|
||||
import { app, BrowserWindow, ipcMain } from 'electron';
|
||||
import { fromPath } from 'id3js';
|
||||
import path from 'node:path';
|
||||
import { dirname } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { readdir, promises } from 'fs';
|
||||
|
||||
// initialize();
|
||||
let win;
|
||||
|
||||
const createWindow = () => {
|
||||
const win = new BrowserWindow({
|
||||
const filename = fileURLToPath(import.meta.url);
|
||||
|
||||
win = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js')
|
||||
preload: path.join(dirname(filename), 'preload.js'),
|
||||
contextIsolation: true
|
||||
}
|
||||
});
|
||||
|
||||
@@ -19,6 +28,18 @@ const createWindow = () => {
|
||||
};
|
||||
|
||||
app.whenReady().then(() => {
|
||||
// ipcMain.handle('getAudioInfo', function(event, url) {
|
||||
// let info;
|
||||
|
||||
// fromUrl(url).then(function(tags) {
|
||||
// info = tags;
|
||||
// }).catch(function(reason) {
|
||||
// console.log(reason);
|
||||
// });
|
||||
|
||||
// return info;
|
||||
// });
|
||||
|
||||
createWindow();
|
||||
|
||||
app.on('activate', () => {
|
||||
@@ -32,4 +53,43 @@ app.on('window-all-closed', () => {
|
||||
app.quit();
|
||||
});
|
||||
|
||||
ipcMain.handle('readMusicLibrary', function(event, path) {
|
||||
let files = promises.readdir(path)
|
||||
.then(function(files) {
|
||||
if (files) {
|
||||
return files;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
return files;
|
||||
});
|
||||
|
||||
ipcMain.handle('getAudioInfo', function(event, url) {
|
||||
let id3tags = fromPath(url).then(function(tags) {
|
||||
return tags;
|
||||
}).catch(function(reason) {
|
||||
console.log(reason);
|
||||
})
|
||||
|
||||
return id3tags;
|
||||
});
|
||||
|
||||
// function getAudioInfo(url) {
|
||||
// let info;
|
||||
|
||||
// fromUrl(url).then((tags) => {
|
||||
// info = tags;
|
||||
// });
|
||||
|
||||
// return info;
|
||||
// }
|
||||
|
||||
// ipcMain.on('A', (event, args) => {
|
||||
|
||||
// });
|
||||
|
||||
Reference in new issue
Block a user