aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/playlist.c')
-rw-r--r--src/playlist.c65
1 files changed, 64 insertions, 1 deletions
diff --git a/src/playlist.c b/src/playlist.c
index 1f7c876ed..e7eb1827d 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -463,6 +463,32 @@ int playlistInfo(FILE * fp, int song) {
return 0;
}
+# define checkSongId(id) { \
+ if(id < 0 || id >= PLAYLIST_HASH_MULT*playlist_max_length || \
+ playlist.idToNum[id] == -1 ) \
+ { \
+ commandError(fp, ACK_ERROR_NO_EXIST, \
+ "song id doesn't exist: \"%i\"", id); \
+ return -1; \
+ } \
+}
+
+int playlistId(FILE * fp, int id) {
+ int i;
+ int begin = 0;
+ int end = playlist.length;
+
+ if(id>=0) {
+ checkSongId(id);
+ begin = playlist.idToNum[id];
+ end = begin+1;
+ }
+
+ for(i=begin; i<end; i++) printPlaylistSongInfo(fp, i);
+
+ return 0;
+}
+
void swapSongs(int song1, int song2) {
Song * sTemp;
int iTemp;
@@ -634,7 +660,6 @@ int swapSongsInPlaylist(FILE * fp, int song1, int song2) {
"song doesn't exist: \"%i\"", song2);
return -1;
}
-
if(playlist_state==PLAYLIST_STATE_PLAY) {
if(playlist.queued>=0) {
@@ -673,6 +698,14 @@ int swapSongsInPlaylist(FILE * fp, int song1, int song2) {
return 0;
}
+int swapSongsInPlaylistById(FILE * fp, int id1, int id2) {
+ checkSongId(id1);
+ checkSongId(id2);
+
+ return swapSongsInPlaylist(fp, playlist.idToNum[id1],
+ playlist.idToNum[id2]);
+}
+
#define moveSongFromTo(from, to) { \
playlist.idToNum[playlist.numToId[from]] = to; \
playlist.numToId[to] = playlist.numToId[from]; \
@@ -748,6 +781,12 @@ int deleteFromPlaylist(FILE * fp, int song) {
return 0;
}
+int deleteFromPlaylistById(FILE * fp, int id) {
+ checkSongId(id);
+
+ return deleteFromPlaylist(fp, playlist.idToNum[id]);
+}
+
void deleteASongFromPlaylist(Song * song) {
int i;
@@ -839,6 +878,16 @@ int playPlaylist(FILE * fp, int song, int stopOnError) {
return playPlaylistOrderNumber(fp,i);
}
+int playPlaylistById(FILE * fp, int id, int stopOnError) {
+ if(id == -1) {
+ return playPlaylist(fp, id, stopOnError);
+ }
+
+ checkSongId(id);
+
+ return playPlaylist(fp, playlist.idToNum[id], stopOnError);
+}
+
void syncCurrentPlayerDecodeMetadata() {
Song * songPlayer = playerCurrentDecodeSong();
Song * song;
@@ -1032,6 +1081,14 @@ int moveSongInPlaylist(FILE * fp, int from, int to) {
return 0;
}
+int moveSongInPlaylistById(FILE * fp, int id1, int id2) {
+ checkSongId(id1);
+ checkSongId(id2);
+
+ return moveSongInPlaylist(fp, playlist.idToNum[id1],
+ playlist.idToNum[id2]);
+}
+
void orderPlaylist() {
int i;
@@ -1398,3 +1455,9 @@ int seekSongInPlaylist(FILE * fp, int song, float time) {
return playerSeek(fp, playlist.songs[playlist.order[i]], time);
}
+
+int seekSongInPlaylistById(FILE * fp, int id, float time) {
+ checkSongId(id);
+
+ return seekSongInPlaylist(fp, playlist.idToNum[id], time);
+}