00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef MPD_PLAYLIST_H
00021 #define MPD_PLAYLIST_H
00022
00023 #include "queue.h"
00024
00025 #include <stdbool.h>
00026 #include <stdio.h>
00027
00028 #define PLAYLIST_COMMENT '#'
00029
00030 enum playlist_result {
00031 PLAYLIST_RESULT_SUCCESS,
00032 PLAYLIST_RESULT_ERRNO,
00033 PLAYLIST_RESULT_DENIED,
00034 PLAYLIST_RESULT_NO_SUCH_SONG,
00035 PLAYLIST_RESULT_NO_SUCH_LIST,
00036 PLAYLIST_RESULT_LIST_EXISTS,
00037 PLAYLIST_RESULT_BAD_NAME,
00038 PLAYLIST_RESULT_BAD_RANGE,
00039 PLAYLIST_RESULT_NOT_PLAYING,
00040 PLAYLIST_RESULT_TOO_LARGE,
00041 PLAYLIST_RESULT_DISABLED,
00042 };
00043
00044 struct playlist {
00048 struct queue queue;
00049
00054 bool playing;
00055
00061 bool stop_on_error;
00062
00068 unsigned error_count;
00069
00075 int current;
00076
00084 int queued;
00085
00091 GTimer *prev_elapsed;
00092 };
00093
00095 extern struct playlist g_playlist;
00096
00097 void initPlaylist(void);
00098
00099 void finishPlaylist(void);
00100
00101 void
00102 playlist_init(struct playlist *playlist);
00103
00104 void
00105 playlist_finish(struct playlist *playlist);
00106
00107 void
00108 playlist_tag_changed(struct playlist *playlist);
00109
00113 static inline const struct queue *
00114 playlist_get_queue(const struct playlist *playlist)
00115 {
00116 return &playlist->queue;
00117 }
00118
00119 void readPlaylistState(FILE *);
00120
00121 void savePlaylistState(FILE *);
00122
00123 void clearPlaylist(struct playlist *playlist);
00124
00125 #ifndef WIN32
00126
00130 enum playlist_result
00131 playlist_append_file(struct playlist *playlist, const char *path, int uid,
00132 unsigned *added_id);
00133 #endif
00134
00135 enum playlist_result
00136 addToPlaylist(struct playlist *playlist, const char *file, unsigned *added_id);
00137
00138 enum playlist_result
00139 addSongToPlaylist(struct playlist *playlist,
00140 struct song *song, unsigned *added_id);
00141
00142 enum playlist_result
00143 deleteFromPlaylist(struct playlist *playlist, unsigned song);
00144
00145 enum playlist_result
00146 deleteFromPlaylistById(struct playlist *playlist, unsigned song);
00147
00148 void stopPlaylist(struct playlist *playlist);
00149
00150 enum playlist_result
00151 playPlaylist(struct playlist *playlist, int song);
00152
00153 enum playlist_result
00154 playPlaylistById(struct playlist *playlist, int song);
00155
00156 void nextSongInPlaylist(struct playlist *playlist);
00157
00158 void syncPlayerAndPlaylist(struct playlist *playlist);
00159
00160 void previousSongInPlaylist(struct playlist *playlist);
00161
00162 void shufflePlaylist(struct playlist *playlist, unsigned start, unsigned end);
00163
00164 void
00165 deleteASongFromPlaylist(struct playlist *playlist, const struct song *song);
00166
00167 enum playlist_result
00168 moveSongRangeInPlaylist(struct playlist *playlist, unsigned start, unsigned end, int to);
00169
00170 enum playlist_result
00171 moveSongInPlaylistById(struct playlist *playlist, unsigned id, int to);
00172
00173 enum playlist_result
00174 swapSongsInPlaylist(struct playlist *playlist, unsigned song1, unsigned song2);
00175
00176 enum playlist_result
00177 swapSongsInPlaylistById(struct playlist *playlist, unsigned id1, unsigned id2);
00178
00179 bool
00180 getPlaylistRepeatStatus(const struct playlist *playlist);
00181
00182 void setPlaylistRepeatStatus(struct playlist *playlist, bool status);
00183
00184 bool
00185 getPlaylistRandomStatus(const struct playlist *playlist);
00186
00187 void setPlaylistRandomStatus(struct playlist *playlist, bool status);
00188
00189 bool
00190 getPlaylistSingleStatus(const struct playlist *playlist);
00191
00192 void setPlaylistSingleStatus(struct playlist *playlist, bool status);
00193
00194 bool
00195 getPlaylistConsumeStatus(const struct playlist *playlist);
00196
00197 void setPlaylistConsumeStatus(struct playlist *playlist, bool status);
00198
00199 int getPlaylistCurrentSong(const struct playlist *playlist);
00200
00201 int getPlaylistNextSong(const struct playlist *playlist);
00202
00203 unsigned
00204 getPlaylistSongId(const struct playlist *playlist, unsigned song);
00205
00206 int getPlaylistLength(const struct playlist *playlist);
00207
00208 unsigned long
00209 getPlaylistVersion(const struct playlist *playlist);
00210
00211 enum playlist_result
00212 seekSongInPlaylist(struct playlist *playlist, unsigned song, float seek_time);
00213
00214 enum playlist_result
00215 seekSongInPlaylistById(struct playlist *playlist,
00216 unsigned id, float seek_time);
00217
00218 void playlistVersionChange(struct playlist *playlist);
00219
00220 int is_valid_playlist_name(const char *utf8path);
00221
00222 #endif