mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 05:08:04 +00:00
feat: send current track to main process and provide an api
This commit is contained in:
parent
c564d03c17
commit
07455c8ecd
3 changed files with 15 additions and 0 deletions
|
|
@ -88,6 +88,9 @@ class Background {
|
|||
const expressApp = express();
|
||||
expressApp.use('/', express.static(__dirname + '/'));
|
||||
expressApp.use('/api', expressProxy('http://127.0.0.1:10754'));
|
||||
expressApp.use('/player', (req, res) => {
|
||||
res.send(this.store.get('playerInfo'));
|
||||
});
|
||||
this.expressApp = expressApp.listen(27232);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,4 +121,8 @@ export function initIpcMain(win, store) {
|
|||
console.log('removeProxy');
|
||||
win.webContents.session.setProxy({});
|
||||
});
|
||||
|
||||
ipcMain.on('playerInfo', (event, info) => {
|
||||
store.set('playerInfo', info);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,6 +177,14 @@ export default class {
|
|||
setInterval(() => {
|
||||
this._progress = this._howler === null ? 0 : this._howler.seek();
|
||||
}, 1000);
|
||||
|
||||
// 发送正在播放的信息给主进程
|
||||
setInterval(() => {
|
||||
ipcRenderer.send('playerInfo', {
|
||||
currentTrack: this.currentTrack,
|
||||
progress: this._progress,
|
||||
});
|
||||
}, 1000);
|
||||
}
|
||||
_getNextTrack() {
|
||||
if (this._playNextList.length > 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue