moritz-weber / mucke

mucke - android music player
GNU General Public License v3.0
226 stars 12 forks source link

Implement stop looping mode #118

Closed FriederHannenheim closed 1 year ago

FriederHannenheim commented 1 year ago

Fixes #102

I'm opening this pull request because I need help implementing it. The solution I found now kinda works but it stops playback when the current song is almost done playing and also when changing the queue. just_audio sadly doesn't support this use case.

Do you have an Idea on how to implement this?

moritz-weber commented 1 year ago

_currentSongSubject gets updated when a song changes, this includes when a song counts as played (counter is increased). Thus, this triggers the pause. Maybe there is a better stream to listen to (directly from the AudioPlayer) or you could store the current song and check if there is actually a new song/new index.

FriederHannenheim commented 1 year ago

It works now, though this is a bit of a hack. It works well on my device and 250 ms is a safe value that doesn't impact the listening experience but I'm not sure how it will perform on lower-end devices.

moritz-weber commented 1 year ago

Thanks for your contribution. I found this solution to work very well, though 250ms felt a bit long. I adjusted the position stream to update at least every 100ms and reduced the threshold to 101ms. Let's just see how this works out; breaking this wouldn't be a huge issue in my opinion, and raising the threshold would be an easy fix.

I also created a new icon for the stop mode. As a rule of thumb, I always use the rounded version of the material icons.