Random replay in QMediaPlayer #40

Open
opened 2026-05-24 14:35:46 +00:00 by pavel · 0 comments
Contributor

Switch to the next song is implemented as below, which bypasses issue when QMediaPlayer doesn't report EndOfMedia status in the end of mp3. But position changed is reported with milliseconds precision once in a second and looks like notification period can't be adjusted in this version. This means that randomly end of song will not be processed and song will start from the beginning (although loops are set to 1 and it shouldn't). A lot of strange things happening here, need to dig deeper in QMediaPlayer behavior.

onPositionChanged: {
            var p = appWindow.player
            if (p.duration > 0 && p.position >= p.duration - 200) {
                Logger.debug("Player", "Position is enough for song change")
                onSongFinished()
            }
Switch to the next song is implemented as below, which bypasses issue when QMediaPlayer doesn't report EndOfMedia status in the end of mp3. But position changed is reported with milliseconds precision once in a second and looks like notification period can't be adjusted in this version. This means that randomly end of song will not be processed and song will start from the beginning (although loops are set to 1 and it shouldn't). A lot of strange things happening here, need to dig deeper in QMediaPlayer behavior. ``` onPositionChanged: { var p = appWindow.player if (p.duration > 0 && p.position >= p.duration - 200) { Logger.debug("Player", "Position is enough for song change") onSongFinished() } ```
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jakub/SubMusic#40
No description provided.