implement ability to jump by queue position/id

This commit is contained in:
Adrian Ulrich 2012-09-29 20:14:48 +02:00
parent 669bf3f4b8
commit eda55a01bb
2 changed files with 31 additions and 1 deletions

View File

@ -1898,4 +1898,19 @@ public final class PlaybackService extends Service
{
return mTimeline.getLength();
}
/**
* Returns 'Song' with given id from timeline
*/
public Song getSongByQueuePosition(int id) {
return mTimeline.getSongByQueuePosition(id);
}
public void jumpToQueuePosition(int id) {
pause();
mTimeline.setCurrentQueuePosition(id);
setCurrentSong(0);
play();
}
}

View File

@ -557,7 +557,22 @@ public final class SongTimeline {
mCurrentPos = pos;
mShuffledSongs = null;
}
/**
* Hard-Jump to given queue position
*/
public Song setCurrentQueuePosition(int pos) {
mCurrentPos = pos;
return getSong(0);
}
/**
* Returns 'Song' at given position in queue
*/
public Song getSongByQueuePosition(int id) {
return mSongs.get(id);
}
/**
* Move to the next or previous song or album.
*