set FLAG_RANDOM for songs picked automatically

This commit is contained in:
Adrian Ulrich 2016-10-30 14:32:42 +01:00
parent ca3ce0897c
commit 0729e4d96a
2 changed files with 3 additions and 2 deletions

View File

@ -575,7 +575,7 @@ public class MediaUtils {
* *
* @param resolver A ContentResolver to use. * @param resolver A ContentResolver to use.
*/ */
public static Song randomSong(ContentResolver resolver) public static Song getRandomSong(ContentResolver resolver)
{ {
long[] songs = sAllSongs; long[] songs = sAllSongs;
@ -591,6 +591,7 @@ public class MediaUtils {
} }
Song result = getSongByTypeId(resolver, MediaUtils.TYPE_SONG, sAllSongs[sAllSongsIdx]); Song result = getSongByTypeId(resolver, MediaUtils.TYPE_SONG, sAllSongs[sAllSongsIdx]);
result.flags |= Song.FLAG_RANDOM;
sAllSongsIdx++; sAllSongsIdx++;
return result; return result;
} }

View File

@ -554,7 +554,7 @@ public final class SongTimeline {
return null; return null;
} else if (pos == size) { } else if (pos == size) {
if (mFinishAction == FINISH_RANDOM) { if (mFinishAction == FINISH_RANDOM) {
song = MediaUtils.randomSong(mContext.getContentResolver()); song = MediaUtils.getRandomSong(mContext.getContentResolver());
if (song == null) if (song == null)
return null; return null;
timeline.add(song); timeline.add(song);