summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/onplay.c8
-rw-r--r--apps/playlist.c12
-rw-r--r--apps/playlist.h1
3 files changed, 17 insertions, 4 deletions
diff --git a/apps/onplay.c b/apps/onplay.c
index 5dcbe6e13e..6ff99d7dd1 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -314,6 +314,14 @@ static bool playlist_options(void)
args[i].position = PLAYLIST_INSERT;
args[i].queue = false;
i++;
+
+ if (selected_file_attr & ATTR_DIRECTORY)
+ {
+ items[i].desc = ID2P(LANG_INSERT_SHUFFLED);
+ args[i].position = PLAYLIST_INSERT_SHUFFLED;
+ args[i].queue = false;
+ i++;
+ }
}
}
diff --git a/apps/playlist.c b/apps/playlist.c
index f11cb04370..86e963a51c 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -223,6 +223,7 @@ static void empty_playlist(struct playlist_info* playlist, bool resume)
playlist->shuffle_modified = false;
playlist->deleted = false;
playlist->num_inserted_tracks = 0;
+ playlist->started = false;
playlist->num_cached = 0;
playlist->pending_control_sync = false;
@@ -602,7 +603,7 @@ static int add_track_to_playlist(struct playlist_info* playlist,
break;
case PLAYLIST_INSERT_SHUFFLED:
{
- if (playlist->amount > 0)
+ if (playlist->started)
{
int offset;
int n = playlist->amount -
@@ -620,7 +621,7 @@ static int add_track_to_playlist(struct playlist_info* playlist,
insert_position = position;
}
else
- position = insert_position = 0;
+ position = insert_position = (rand() % (playlist->amount+1));
break;
}
}
@@ -639,11 +640,12 @@ static int add_track_to_playlist(struct playlist_info* playlist,
}
/* update stored indices if needed */
- if (playlist->amount > 0 && insert_position <= playlist->index)
+ if (playlist->amount > 0 && insert_position <= playlist->index &&
+ playlist->started)
playlist->index++;
if (playlist->amount > 0 && insert_position <= playlist->first_index &&
- position != PLAYLIST_PREPEND)
+ position != PLAYLIST_PREPEND && playlist->started)
{
playlist->first_index++;
@@ -2313,6 +2315,8 @@ int playlist_start(int start_index, int offset)
#endif
audio_play(offset);
+ playlist->started = true;
+
return 0;
}
diff --git a/apps/playlist.h b/apps/playlist.h
index 3aa5406a51..1a5bb3d33c 100644
--- a/apps/playlist.h
+++ b/apps/playlist.h
@@ -90,6 +90,7 @@ struct playlist_info
inserted tracks? */
bool deleted; /* have any tracks been deleted? */
int num_inserted_tracks; /* number of tracks inserted */
+ bool started; /* has playlist been started? */
/* cache of playlist control commands waiting to be flushed to
to disk */