mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-25 22:55:56 -05:00
Change behavior of skip to previous song to start the current song from
the beginning, if it is playing for more than 3 seconds
This commit is contained in:
parent
b195e76f11
commit
4d79a85780
24
src/player.c
24
src/player.c
@ -2633,6 +2633,7 @@ static int
|
||||
playback_prev_bh(struct player_command *cmd)
|
||||
{
|
||||
int ret;
|
||||
int pos_sec;
|
||||
|
||||
if (!cur_streaming)
|
||||
{
|
||||
@ -2646,6 +2647,17 @@ playback_prev_bh(struct player_command *cmd)
|
||||
|
||||
source_stop(cur_streaming);
|
||||
|
||||
/* Compute the playing time in seconds for the current song. */
|
||||
if (cur_streaming->end > cur_streaming->stream_start)
|
||||
pos_sec = (cur_streaming->end - cur_streaming->stream_start) / 44100;
|
||||
else
|
||||
pos_sec = 0;
|
||||
|
||||
/* Only skip to the previous song if the playing time is less than 3 seconds,
|
||||
otherwise restart the current song. */
|
||||
DPRINTF(E_DBG, L_PLAYER, "Skipping song played %d sec\n", pos_sec);
|
||||
if (pos_sec < 3)
|
||||
{
|
||||
ret = source_prev();
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -2653,6 +2665,17 @@ playback_prev_bh(struct player_command *cmd)
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = source_open(cur_streaming, 1);
|
||||
if (ret < 0)
|
||||
{
|
||||
playback_abort();
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (player_state == PLAY_STOPPED)
|
||||
return -1;
|
||||
@ -2668,6 +2691,7 @@ playback_prev_bh(struct player_command *cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
playback_next_bh(struct player_command *cmd)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user