Skip to content

Commit 1985778

Browse files
fix
1 parent cdaa353 commit 1985778

5 files changed

Lines changed: 24 additions & 5 deletions

File tree

docs/ipc.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,15 @@ export const rem: EventEmitter
2929
```
3030
3131
32+
33+
34+
35+
### 插件窗口IPC服务器
36+
37+
38+
39+
#### 服务器
40+
41+
```ts
42+
```
43+

extension/vendor/control-widget/ui/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ const update = subscribe('playstate', ([ playing, progress ]) => {
1010
.removeClass(playing ? "fa-play" : "fa-pause")
1111
.addClass(playing ? "fa-pause" : "fa-play")
1212
})
13+
const playerUpdate = subscribe('player', render)
1314

1415
win.beforeClose = () => {
1516
player.destroy()
1617
update.destroy()
1718
playlist.destroy()
19+
playerUpdate.destroy()
1820
}
1921

2022
render()
@@ -50,5 +52,5 @@ async function render() {
5052
$(".name").text(name)
5153
$(".singer-album").text(ar.map(a => a.name).join(', ') + " - " + al.name)
5254
$(".time").text(duration)
53-
document.getElementById('img').src = al.picUrl
55+
$("#img").attr("src", al.picUrl)
5456
}

pages/components/Control.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import { globalMetadata } from '../../utils/player/metadata.js'
55
import { MainPlaylist } from '../../utils/player/playlist.js'
66
import { rem, LifeCycle } from '../../utils/rem.js'
7-
import { vsync } from '../../utils/core/vsync.js'
87
import { store } from '../../utils/stores/base.js'
98
import { getColor } from '../../utils/style/imageBasicColor.js'
109
import Link from "./Link.svelte"

utils/ipc/main.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@ const { ipcMain } = require('electron')
33

44
let channels = new Map()
55

6-
module.exports = () => {
7-
ipcMain.on('win:playstate', (e, ...args) => {
8-
const channel = channels.get('playstate')
6+
function delegate(from, to) {
7+
ipcMain.on(from, (e, ...args) => {
8+
const channel = channels.get(to)
99
if (channel) {
1010
channel.forEach(s => {
1111
s.write(JSON.stringify(args) + '\0')
1212
})
1313
}
1414
})
15+
}
16+
17+
module.exports = () => {
18+
delegate('win:playstate', 'playstate')
19+
delegate('win:player', 'player')
1520

1621
provide('subscribe', s => {
1722
s.on('data', data => {

utils/player/player.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ LifeCycle.when('runtimeReady').then(() => {
193193
AudioPlayer.on('play', () => AudioPlayer.isPlayingIgnoreFade = true)
194194
AudioPlayer.on('pause', () => AudioPlayer.isPlayingIgnoreFade = false)
195195
AudioPlayer.on('ended', () => AudioPlayer.isPlayingIgnoreFade = false)
196+
AudioPlayer.on('loadedContent', () => hooks.send('win:player', structuredClone(AudioPlayer.audioData?.data)))
196197

197198
navigator.mediaSession.setActionHandler('play', () => globalPlayer.play())
198199
navigator.mediaSession.setActionHandler('pause', () => globalPlayer.pause())

0 commit comments

Comments
 (0)