2 * Copyright (C) 2003-2010 The Music Player Daemon Project
3 * http://www.musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef MPD_PLAYLIST_H
21 #define MPD_PLAYLIST_H
27 #define PLAYLIST_COMMENT '#'
29 enum playlist_result
{
30 PLAYLIST_RESULT_SUCCESS
,
31 PLAYLIST_RESULT_ERRNO
,
32 PLAYLIST_RESULT_DENIED
,
33 PLAYLIST_RESULT_NO_SUCH_SONG
,
34 PLAYLIST_RESULT_NO_SUCH_LIST
,
35 PLAYLIST_RESULT_LIST_EXISTS
,
36 PLAYLIST_RESULT_BAD_NAME
,
37 PLAYLIST_RESULT_BAD_RANGE
,
38 PLAYLIST_RESULT_NOT_PLAYING
,
39 PLAYLIST_RESULT_TOO_LARGE
,
40 PLAYLIST_RESULT_DISABLED
,
45 * The song queue - it contains the "real" playlist.
50 * This value is true if the player is currently playing (or
56 * If true, then any error is fatal; if false, MPD will
57 * attempt to play the next song on non-fatal errors. During
58 * seeking, this flag is set.
63 * Number of errors since playback was started. If this
64 * number exceeds the length of the playlist, MPD gives up,
65 * because all songs have been tried.
70 * The "current song pointer". This is the song which is
71 * played when we get the "play" command. It is also the song
72 * which is currently being played.
77 * The "next" song to be played, when the current one
78 * finishes. The decoder thread may start decoding and
79 * buffering it, while the "current" song is still playing.
81 * This variable is only valid if #playing is true.
86 /** the global playlist object */
87 extern struct playlist g_playlist
;
90 playlist_global_init(void);
93 playlist_global_finish(void);
96 playlist_init(struct playlist
*playlist
);
99 playlist_finish(struct playlist
*playlist
);
102 playlist_tag_changed(struct playlist
*playlist
);
105 * Returns the "queue" object of the global playlist instance.
107 static inline const struct queue
*
108 playlist_get_queue(const struct playlist
*playlist
)
110 return &playlist
->queue
;
114 playlist_clear(struct playlist
*playlist
);
118 * Appends a local file (outside the music database) to the playlist,
119 * but only if the file's owner is equal to the specified uid.
122 playlist_append_file(struct playlist
*playlist
, const char *path
, int uid
,
127 playlist_append_uri(struct playlist
*playlist
, const char *file
,
131 playlist_append_song(struct playlist
*playlist
,
132 struct song
*song
, unsigned *added_id
);
135 playlist_delete(struct playlist
*playlist
, unsigned song
);
138 * Deletes a range of songs from the playlist.
140 * @param start the position of the first song to delete
141 * @param end the position after the last song to delete
144 playlist_delete_range(struct playlist
*playlist
, unsigned start
, unsigned end
);
147 playlist_delete_id(struct playlist
*playlist
, unsigned song
);
150 playlist_stop(struct playlist
*playlist
);
153 playlist_play(struct playlist
*playlist
, int song
);
156 playlist_play_id(struct playlist
*playlist
, int song
);
159 playlist_next(struct playlist
*playlist
);
162 playlist_sync(struct playlist
*playlist
);
165 playlist_previous(struct playlist
*playlist
);
168 playlist_shuffle(struct playlist
*playlist
, unsigned start
, unsigned end
);
171 playlist_delete_song(struct playlist
*playlist
, const struct song
*song
);
174 playlist_move_range(struct playlist
*playlist
, unsigned start
, unsigned end
, int to
);
177 playlist_move_id(struct playlist
*playlist
, unsigned id
, int to
);
180 playlist_swap_songs(struct playlist
*playlist
, unsigned song1
, unsigned song2
);
183 playlist_swap_songs_id(struct playlist
*playlist
, unsigned id1
, unsigned id2
);
186 playlist_get_repeat(const struct playlist
*playlist
);
189 playlist_set_repeat(struct playlist
*playlist
, bool status
);
192 playlist_get_random(const struct playlist
*playlist
);
195 playlist_set_random(struct playlist
*playlist
, bool status
);
198 playlist_get_single(const struct playlist
*playlist
);
201 playlist_set_single(struct playlist
*playlist
, bool status
);
204 playlist_get_consume(const struct playlist
*playlist
);
207 playlist_set_consume(struct playlist
*playlist
, bool status
);
210 playlist_get_current_song(const struct playlist
*playlist
);
213 playlist_get_next_song(const struct playlist
*playlist
);
216 playlist_get_song_id(const struct playlist
*playlist
, unsigned song
);
219 playlist_get_length(const struct playlist
*playlist
);
222 playlist_get_version(const struct playlist
*playlist
);
225 playlist_seek_song(struct playlist
*playlist
, unsigned song
, float seek_time
);
228 playlist_seek_song_id(struct playlist
*playlist
,
229 unsigned id
, float seek_time
);
232 playlist_increment_version_all(struct playlist
*playlist
);