Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleaning up player_skip_song

  • Loading branch information...
commit b8c9e0a29fb083366952da57ed61f92b957d0e1c 1 parent 0f7330d
John Altenmueller authored
Showing with 8 additions and 51 deletions.
  1. +8 −51 player.c
59 player.c
View
@@ -162,50 +162,16 @@ player_seek(int seconds)
player.seek(seconds);
}
-/* TODO merge this with the player_play_prev_song into player_skip_song */
void
-player_play_next_song(int skip)
-{
- if (!player.playing())
- return;
-
- switch (player_info.mode) {
- case MODE_LINEAR:
- player_info.qidx += skip;
- if (player_info.qidx >= player_info.queue->nfiles) {
- player_info.qidx = 0;
- player_stop();
- } else
- player_play();
-
- break;
-
- case MODE_LOOP:
- player_info.qidx += skip;
- if (player_info.qidx >= player_info.queue->nfiles)
- player_info.qidx %= player_info.queue->nfiles;
-
- player_play();
- break;
-
- case MODE_RANDOM:
- player_info.qidx = rand() % player_info.queue->nfiles;
- player_play();
- break;
- }
-}
-
-/* TODO (see comment for player_play_next_song) */
-void
-player_play_prev_song(int skip)
+player_skip_song(int num)
{
if (!player.playing())
return;
switch (player_info.mode) {
case MODE_LINEAR:
- player_info.qidx -= skip;
- if (player_info.qidx < 0) {
+ player_info.qidx += num;
+ if (player_info.qidx >= player_info.queue->nfiles || player_info.qidx < 0) {
player_info.qidx = 0;
player_stop();
} else
@@ -214,11 +180,12 @@ player_play_prev_song(int skip)
break;
case MODE_LOOP:
- skip %= player_info.queue->nfiles;
- if (skip <= player_info.qidx)
- player_info.qidx -= skip;
+ player_info.qidx += num;
+ if ( player_info.qidx < 0 )
+ player_info.qidx += ( abs( player_info.qidx / player_info.queue->nfiles ) + 1 )
+ * player_info.queue->nfiles;
else
- player_info.qidx = player_info.queue->nfiles - (skip + player_info.qidx);
+ player_info.qidx %= player_info.queue->nfiles;
player_play();
break;
@@ -230,16 +197,6 @@ player_play_prev_song(int skip)
}
}
-/* TODO merge with above... wtf didn't i do it that way!? */
-void
-player_skip_song(int num)
-{
- if (num >= 0)
- player_play_next_song(num);
- else
- player_play_prev_song(num * -1);
-}
-
void
player_volume_step(float percent)
{
Please sign in to comment.
Something went wrong with that request. Please try again.