Fixed another playing queue related bug

This commit is contained in:
Karim Abou Zeid 2015-12-24 21:35:49 +01:00
commit cbe8751ce0
3 changed files with 37 additions and 22 deletions

View file

@ -167,7 +167,7 @@ public class MusicPlayerRemote {
*/
public static void openQueue(final ArrayList<Song> queue, final int startPosition, final boolean startPlaying) {
if (!tryToHandleOpenPlayingQueue(queue, startPosition, startPlaying) && musicService != null) {
musicService.openAndPlayQueue(queue, startPosition, startPlaying);
musicService.openQueue(queue, startPosition, startPlaying);
}
}
@ -280,7 +280,13 @@ public class MusicPlayerRemote {
public static boolean playNext(Song song) {
if (musicService != null) {
musicService.addSong(getPosition() + 1, song);
if (getPlayingQueue().size() > 0) {
musicService.addSong(getPosition() + 1, song);
} else {
ArrayList<Song> queue = new ArrayList<>();
queue.add(song);
openQueue(queue, 0, false);
}
Toast.makeText(musicService, musicService.getResources().getString(R.string.added_title_to_playing_queue), Toast.LENGTH_SHORT).show();
return true;
}
@ -289,7 +295,13 @@ public class MusicPlayerRemote {
public static boolean enqueue(Song song) {
if (musicService != null) {
musicService.addSong(song);
if (getPlayingQueue().size() > 0) {
musicService.addSong(song);
} else {
ArrayList<Song> queue = new ArrayList<>();
queue.add(song);
openQueue(queue, 0, false);
}
Toast.makeText(musicService, musicService.getResources().getString(R.string.added_title_to_playing_queue), Toast.LENGTH_SHORT).show();
return true;
}
@ -298,7 +310,11 @@ public class MusicPlayerRemote {
public static boolean enqueue(@NonNull ArrayList<Song> songs) {
if (musicService != null) {
musicService.addSongs(songs);
if (getPlayingQueue().size() > 0) {
musicService.addSongs(songs);
} else {
openQueue(songs, 0, false);
}
final String toast = songs.size() == 1 ? musicService.getResources().getString(R.string.added_title_to_playing_queue) : musicService.getResources().getString(R.string.added_x_titles_to_playing_queue, songs.size());
Toast.makeText(musicService, toast, Toast.LENGTH_SHORT).show();
return true;