feat: 播放器核心集成;MediaSession集成

This commit is contained in:
lqtmcstudio
2026-02-02 21:27:48 +08:00
parent 9fc08c59d7
commit 6965858ae3
8 changed files with 286 additions and 75 deletions

View File

@@ -20,6 +20,16 @@ const router = createRouter({
path: '/local',
name: 'Local',
component: () => import('./views/LocalMusic.vue')
},
{
path: '/liked',
name: 'Liked',
component: () => import('./views/Playlist.vue')
},
{
path: '/recent',
name: 'Recent',
component: () => import('./views/Playlist.vue')
}
]
})
@@ -28,4 +38,29 @@ const app = createApp(App)
app.use(pinia)
app.use(router)
app.use(TDesign)
app.mount('#app')
app.mount('#app')
// --- TEST: Auto Play Specific Song ---
import { usePlayerStore, PlayMode } from './stores/player'
import type { Song } from './types/song'
const playerStore = usePlayerStore()
// Set Single Mode
playerStore.playMode = PlayMode.Single;
const testSong: Song = {
id: '9999',
name: 'Test FLAC',
artist: 'Netease',
picUrl: 'http://p1.music.126.net/btYBbFLd5mf9w0lDpfNs6w==/109951171506809884.jpg?param=130y130',
url: 'http://m801.music.126.net/20260202213928/189743bba596f8fd999bc44fd51d11fd/jdymusic/obj/wo3DlMOGwrbDjj7DisKw/61393856655/24be/6a68/77e4/fb898a5378682427bf7a4fb55640e610.flac',
duration: '03:30',
source: 'netease',
type: 'Remote'
};
// Auto Play
playerStore.playSong(testSong).then(() => {
playerStore.setPlaylist([testSong]);
});

View File

@@ -3,6 +3,16 @@ export interface IElectronAPI {
maximizeWindow: () => void;
closeWindow: () => void;
isMaximized: () => Promise<boolean>;
mpv: {
load: (url: string) => Promise<void>;
play: () => Promise<void>;
pause: () => Promise<void>;
togglePause: () => Promise<void>;
stop: () => Promise<void>;
setVolume: (vol: number) => Promise<void>;
seek: (time: number) => Promise<void>;
onEvent: (callback: (event: any, data: any) => void) => void;
}
}
declare global {