implement "play next"
This commit is contained in:
1 parent
18bc1fb319
commit
57cbf181a1
4 files changed
+36
-5
No files matched your search
@@ -60,6 +60,7 @@ THE SOFTWARE.
|
||||
|
||||
<!-- Library -->
|
||||
<string name="enqueue">Enqueue</string>
|
||||
<string name="enqueue_as_next">Play Next</string>
|
||||
<string name="play">Play</string>
|
||||
<string name="edit">Edit</string>
|
||||
<string name="rename">Rename</string>
|
||||
|
||||
@@ -104,12 +104,17 @@ public class LibraryActivity
|
||||
* Action for row click: expand the row.
|
||||
*/
|
||||
public static final int ACTION_EXPAND = 6;
|
||||
/**
|
||||
* Action for row click: queue selection as next item
|
||||
*/
|
||||
public static final int ACTION_ENQUEUE_AS_NEXT = 7;
|
||||
/**
|
||||
* The SongTimeline add song modes corresponding to each relevant action.
|
||||
*/
|
||||
private static final int[] modeForAction =
|
||||
{ SongTimeline.MODE_PLAY, SongTimeline.MODE_ENQUEUE, -1,
|
||||
SongTimeline.MODE_PLAY_ID_FIRST, SongTimeline.MODE_ENQUEUE_ID_FIRST };
|
||||
SongTimeline.MODE_PLAY_ID_FIRST, SongTimeline.MODE_ENQUEUE_ID_FIRST,
|
||||
-1, -1, SongTimeline.MODE_ENQUEUE_AS_NEXT };
|
||||
|
||||
private static final String SEARCH_BOX_VISIBLE = "search_box_visible";
|
||||
|
||||
@@ -647,9 +652,10 @@ public class LibraryActivity
|
||||
private static final int MENU_PLAY = 0;
|
||||
private static final int MENU_ENQUEUE = 1;
|
||||
private static final int MENU_EXPAND = 2;
|
||||
private static final int MENU_ADD_TO_PLAYLIST = 3;
|
||||
private static final int MENU_NEW_PLAYLIST = 4;
|
||||
private static final int MENU_DELETE = 5;
|
||||
private static final int MENU_ENQUEUE_AS_NEXT = 3;
|
||||
private static final int MENU_ADD_TO_PLAYLIST = 4;
|
||||
private static final int MENU_NEW_PLAYLIST = 5;
|
||||
private static final int MENU_DELETE = 6;
|
||||
private static final int MENU_RENAME_PLAYLIST = 7;
|
||||
private static final int MENU_SELECT_PLAYLIST = 8;
|
||||
private static final int MENU_PLAY_ALL = 9;
|
||||
@@ -675,6 +681,7 @@ public class LibraryActivity
|
||||
|
||||
menu.setHeaderTitle(rowData.getStringExtra(LibraryAdapter.DATA_TITLE));
|
||||
menu.add(0, MENU_PLAY, 0, R.string.play).setIntent(rowData);
|
||||
menu.add(0, MENU_ENQUEUE_AS_NEXT, 0, R.string.enqueue_as_next).setIntent(rowData);
|
||||
menu.add(0, MENU_ENQUEUE, 0, R.string.enqueue).setIntent(rowData);
|
||||
if (type == MediaUtils.TYPE_PLAYLIST) {
|
||||
menu.add(0, MENU_RENAME_PLAYLIST, 0, R.string.rename).setIntent(rowData);
|
||||
@@ -729,6 +736,9 @@ public class LibraryActivity
|
||||
case MENU_ENQUEUE_ALL:
|
||||
pickSongs(intent, ACTION_ENQUEUE_ALL);
|
||||
break;
|
||||
case MENU_ENQUEUE_AS_NEXT:
|
||||
pickSongs(intent, ACTION_ENQUEUE_AS_NEXT);
|
||||
break;
|
||||
case MENU_NEW_PLAYLIST: {
|
||||
PlaylistTask playlistTask = new PlaylistTask(-1, null);
|
||||
playlistTask.query = buildQueryFromIntent(intent, true, false);
|
||||
|
||||
@@ -1572,6 +1572,7 @@ public final class PlaybackService extends Service
|
||||
case SongTimeline.MODE_ENQUEUE:
|
||||
case SongTimeline.MODE_ENQUEUE_ID_FIRST:
|
||||
case SongTimeline.MODE_ENQUEUE_POS_FIRST:
|
||||
case SongTimeline.MODE_ENQUEUE_AS_NEXT:
|
||||
text = R.plurals.enqueued;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -145,6 +145,14 @@ public final class SongTimeline {
|
||||
* @see SongTimeline#addSongs(Context, QueryTask)
|
||||
*/
|
||||
public static final int MODE_ENQUEUE_POS_FIRST = 6;
|
||||
/**
|
||||
* Enqueues the result as next item(s)
|
||||
*
|
||||
* Pass the position in QueryTask.data.
|
||||
*
|
||||
* @see SongTimeline#addSongs(Context, QueryTask)
|
||||
*/
|
||||
public static final int MODE_ENQUEUE_AS_NEXT = 7;
|
||||
|
||||
/**
|
||||
* Disable shuffle.
|
||||
@@ -657,6 +665,7 @@ public final class SongTimeline {
|
||||
case MODE_ENQUEUE:
|
||||
case MODE_ENQUEUE_POS_FIRST:
|
||||
case MODE_ENQUEUE_ID_FIRST:
|
||||
case MODE_ENQUEUE_AS_NEXT:
|
||||
if (mFinishAction == FINISH_RANDOM) {
|
||||
int j = timeline.size();
|
||||
while (--j > mCurrentPos) {
|
||||
@@ -681,11 +690,21 @@ public final class SongTimeline {
|
||||
int start = timeline.size();
|
||||
|
||||
Song jumpSong = null;
|
||||
int addAtPos = mCurrentPos + 1;
|
||||
|
||||
/* Check if addAtPos is out-of-bounds OR if
|
||||
* the request does not want to work at the current
|
||||
* playlist position anyway
|
||||
*/
|
||||
if (addAtPos > start || mode != MODE_ENQUEUE_AS_NEXT) {
|
||||
addAtPos = start;
|
||||
}
|
||||
|
||||
for (int j = 0; j != count; ++j) {
|
||||
cursor.moveToPosition(j);
|
||||
Song song = new Song(-1);
|
||||
song.populate(cursor);
|
||||
timeline.add(song);
|
||||
timeline.add(addAtPos++, song);
|
||||
|
||||
if (jumpSong == null) {
|
||||
if ((mode == MODE_PLAY_POS_FIRST || mode == MODE_ENQUEUE_POS_FIRST) && j == data) {
|
||||
|
||||
Reference in new issue
Block a user