geigi / cozy

🎧 Listen to audio books 📚 on Linux
https://cozy.sh
GNU General Public License v3.0
1.09k stars 84 forks source link

MPRIS: seek calls only advance to next chapter #781

Open grahamvh opened 1 year ago

grahamvh commented 1 year ago

Bug/Feature description

Any call of the MPRIS seek function(https://github.com/geigi/cozy/blob/1b640d1f61aa8a610a91427567c0d7f2df4e86bd/cozy/control/mpris.py#L230) in cozy causes it to skip to the next chapter. This is most apparent when running cozy inside of phosh, as it has music controls that offer a skip ahead 30 seconds and go back 10 seconds.

Steps to reproduce

Use phosh or other mpris based media controller to try to skip ahead or behind, and it will always send you to the next chapter.

System Information

grahamvh commented 1 year ago

From what I can tell, inside the Seek function the self._player.position, seems to return a seemingly random large integer(not sure why) here

grahamvh commented 8 months ago

I've tested out the latest master branch (hash 1be8d73c740cd6dfca2a7192c8bc509de806cb14) which appears to have the mentioned merge request applied. I don't see any change in the behavior for this issue. This is not fixed.

Thanks for working on it though! It's likely closer.

rdbende commented 8 months ago

This is not fixed.

I'm not sure why then. It works correctly for me with ~GNOME Shell's built-in media controls~ (incorrect, since it only has forward and rewind buttons, not jump x seconds), and with any MPRIS control extension I've tried, and also by manually calling the MPRIS method on DBus.

grahamvh commented 8 months ago

Interesting, I'll try to run some experiments on it when I get a chance. I should have lots of time this weekend.

In the meantime this is what I was testing using: OS: Pureos 10 (byzantium) Arch: Arm64 Install: Flatpak (build from master branch with: flatpak-builder build-dir --force-clean -vvvv com.github.geigi.cozy.json && flatpak-builder --user --install build-dir --force-clean com.github.geigi.cozy.json) MPRIS handler: Phosh built-in, hitting the +30sec and -10sec buttons on the top dropdown.

I plan to capture the seek function inputs when pressing those buttons, and the self._player.position when just playing the audiobook. From what I recall from looking at this before, just capturing what was stored in self._player.position gave some really bizzare results when just listening to a chapter without trying to seek.

rdbende commented 8 months ago

self._player.position still returns insanely large numers (nanoseconds), but it's now properly divided in the MPRIS code. I didn't fix the position getter yet, as it requires some other, relatively big refactorings in the player code, but yeah, the MPRIS part should be fine.

rdbende commented 8 months ago

Can you please record what numbers are sent to the MPRIS seek method? If I'm not mistaken, they should be 10 and 30 million

grahamvh commented 8 months ago

Yep, 30,000,000 and -10,000,000 is that the seek function is receiving. It sounds like the getter needs to be fixed in order to stop this from just moving to the next chapter? Would you like a separate issue?

rdbende commented 8 months ago

I don't mind a separate issue, but you can also reopen this one (I can't), since the bug remains the same.

grahamvh commented 8 months ago

Sadly it won't let me rei=open it either. @geigi ?

rdbende commented 8 months ago

@grahamvh it works for me with Phosh 0.33.0 on an ASUS tablet.

grahamvh commented 8 months ago

Ok after more testing, I've found that the footprint of this is different after the MPRIS update. Before the MPRIS updates this occurred on every book, now there appears to be some specific criteria and circumstances.

Requirements to see the issue: