-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix/mpris reporting #4438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix/mpris reporting #4438
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,11 +27,11 @@ window.ipcRenderer.on( | |
| // Used because 'loadeddata' or 'loadedmetadata' weren't firing on song start for some users (https://github.com/pear-devs/pear-desktop/issues/473) | ||
| const srcChangedEvent = new CustomEvent('peard:src-changed'); | ||
|
|
||
| const getTime = () => songInfo.elapsedSeconds ?? 0; | ||
|
|
||
| export const setupSeekedListener = singleton(() => { | ||
| document.querySelector('video')?.addEventListener('seeked', (v) => { | ||
| if (v.target instanceof HTMLVideoElement) { | ||
| window.ipcRenderer.send('peard:seeked', v.target.currentTime); | ||
| } | ||
| document.querySelector('video')?.addEventListener('seeked', () => { | ||
| window.ipcRenderer.send('peard:seeked', getTime()); | ||
| }); | ||
|
Comment on lines
+30
to
35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reset the front-end elapsed-time cache when a new track starts.
Also applies to: 229-234 🤖 Prompt for AI Agents |
||
| }); | ||
|
|
||
|
|
@@ -227,13 +227,10 @@ export const setupSongInfo = (api: MusicPlayer) => { | |
| }); | ||
|
|
||
| const playPausedHandler = (e: Event, status: string) => { | ||
| if ( | ||
| e.target instanceof HTMLVideoElement && | ||
| Math.round(e.target.currentTime) > 0 | ||
| ) { | ||
| if (e.target instanceof HTMLVideoElement) { | ||
| window.ipcRenderer.send('peard:play-or-paused', { | ||
| isPaused: status === 'pause', | ||
| elapsedSeconds: Math.floor(e.target.currentTime), | ||
| elapsedSeconds: getTime(), | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
For the exact version of@jellybrick/mpris-serviceused in this repository, are PLAYBACK_STATUS_PLAYING / PLAYBACK_STATUS_PAUSED / PLAYBACK_STATUS_STOPPED and LOOP_STATUS_NONE / LOOP_STATUS_TRACK / LOOP_STATUS_PLAYLIST exposed as static properties on the default export, or only as named module exports? Please check the package source or official docs for that version.💡 Result:
The constants PLAYBACK_STATUS_PLAYING, PLAYBACK_STATUS_PAUSED, PLAYBACK_STATUS_STOPPED, LOOP_STATUS_NONE, LOOP_STATUS_TRACK, and LOOP_STATUS_PLAYLIST are exposed only as named module exports, not as static properties on the default export (Player class). Pear-desktop, a likely candidate repository using this package (given the matching scoped name and JellyBrick's contributions), defines these exact constants in its TypeScript declaration file for
@jellybrick/mpris-service(mpris-service.d.ts). They are declared as top-level named exports: export const PLAYBACK_STATUS_PLAYING: 'Playing'; export const PLAYBACK_STATUS_PAUSED: 'Paused'; export const PLAYBACK_STATUS_STOPPED: 'Stopped'; export const LOOP_STATUS_NONE: 'None'; export const LOOP_STATUS_TRACK: 'Track'; export const LOOP_STATUS_PLAYLIST: 'Playlist'; Usage in pear-desktop's mpris.ts confirms named imports: import MprisPlayer, { LOOP_STATUS_NONE, LOOP_STATUS_PLAYLIST, LOOP_STATUS_TRACK, PLAYBACK_STATUS_PAUSED, PLAYBACK_STATUS_PLAYING, PLAYBACK_STATUS_STOPPED, ... } from '@jellybrick/mpris-service'; The package structure includes dist/constants.js (742B), indicating constants are in a separate module file, typical for named exports. The default export is the Player class (new Player({...})), with no evidence of static properties for these values on Player. Properties like player.playbackStatus use the string literals directly (e.g., 'Playing'), but constants are provided as named exports for convenience and type safety.Citations:
🏁 Script executed:
Repository: pear-devs/pear-desktop
Length of output: 267
🏁 Script executed:
Repository: pear-devs/pear-desktop
Length of output: 2097
🏁 Script executed:
Repository: pear-devs/pear-desktop
Length of output: 5777
Replace the type assertion with direct named imports of constants.
The cast at lines 11–19 only satisfies TypeScript; it does not create runtime properties. Since
PLAYBACK_STATUS_PLAYING,PLAYBACK_STATUS_PAUSED,PLAYBACK_STATUS_STOPPED,LOOP_STATUS_NONE,LOOP_STATUS_TRACK, andLOOP_STATUS_PLAYLISTare exported only as named constants (not static properties on the Player class) in@jellybrick/mpris-service@2.1.5, every usage ofMpris.PLAYBACK_STATUS_*andMpris.LOOP_STATUS_*throughout this file will beundefinedat runtime, breaking all status comparisons and assignments.Import the constants directly:
Then remove the type assertion and use the imported constants directly.
🤖 Prompt for AI Agents