playlist.h 4.39 KB
Newer Older
Warren Dukes's avatar
Warren Dukes committed
1
/* the Music Player Daemon (MPD)
2
 * Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com)
Warren Dukes's avatar
Warren Dukes committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * This project's homepage is: http://www.musicpd.org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

19 20
#ifndef MPD_PLAYLIST_H
#define MPD_PLAYLIST_H
Warren Dukes's avatar
Warren Dukes committed
21

Max Kellermann's avatar
Max Kellermann committed
22
#include "locate.h"
Warren Dukes's avatar
Warren Dukes committed
23

24
#include <stdbool.h>
25 26
#include <stdio.h>

27 28
#define PLAYLIST_COMMENT	'#'

29 30
struct client;

31 32 33
enum playlist_result {
	PLAYLIST_RESULT_SUCCESS,
	PLAYLIST_RESULT_ERRNO,
34
	PLAYLIST_RESULT_DENIED,
35 36 37 38 39 40 41 42 43
	PLAYLIST_RESULT_NO_SUCH_SONG,
	PLAYLIST_RESULT_NO_SUCH_LIST,
	PLAYLIST_RESULT_LIST_EXISTS,
	PLAYLIST_RESULT_BAD_NAME,
	PLAYLIST_RESULT_BAD_RANGE,
	PLAYLIST_RESULT_NOT_PLAYING,
	PLAYLIST_RESULT_TOO_LARGE
};

44
typedef struct _Playlist {
45
	struct song **songs;
46
	/* holds version a song was modified on */
47
	uint32_t *songMod;
48 49
	unsigned *order;
	unsigned *positionToId;
50
	int *idToPosition;
51
	unsigned length;
52 53
	int current;
	int queued;
54 55
	bool repeat;
	bool random;
56
	uint32_t version;
57 58 59 60 61

	/** used by syncCurrentPlayerDecodeMetadata() to detect tag changes */
	const struct song *prev_song;
	/** used by syncCurrentPlayerDecodeMetadata() to detect tag changes */
	const struct tag *prev_tag;
62 63
} Playlist;

64
extern bool playlist_saveAbsolutePaths;
Warren Dukes's avatar
Warren Dukes committed
65

66
extern unsigned playlist_max_length;
67

68
void initPlaylist(void);
Warren Dukes's avatar
Warren Dukes committed
69

70
void finishPlaylist(void);
Warren Dukes's avatar
Warren Dukes committed
71

72
void readPlaylistState(FILE *);
Warren Dukes's avatar
Warren Dukes committed
73

74
void savePlaylistState(FILE *);
Warren Dukes's avatar
Warren Dukes committed
75

76
void clearPlaylist(void);
Warren Dukes's avatar
Warren Dukes committed
77

78 79 80 81 82
/**
 * Appends a local file (outside the music database) to the playlist,
 * but only if the file's owner is equal to the specified uid.
 */
enum playlist_result
83
playlist_append_file(const char *path, int uid, unsigned *added_id);
84

85
enum playlist_result addToPlaylist(const char *file, unsigned *added_id);
Warren Dukes's avatar
Warren Dukes committed
86

87
enum playlist_result
88
addSongToPlaylist(struct song *song, unsigned *added_id);
Warren Dukes's avatar
Warren Dukes committed
89

90
void showPlaylist(struct client *client);
Warren Dukes's avatar
Warren Dukes committed
91

92
enum playlist_result deleteFromPlaylist(unsigned song);
Warren Dukes's avatar
Warren Dukes committed
93

94
enum playlist_result deleteFromPlaylistById(unsigned song);
95

96
enum playlist_result playlistInfo(struct client *client, int song);
Warren Dukes's avatar
Warren Dukes committed
97

98
enum playlist_result playlistId(struct client *client, int song);
99

100
void stopPlaylist(void);
Warren Dukes's avatar
Warren Dukes committed
101

102
enum playlist_result playPlaylist(int song, int stopOnError);
Warren Dukes's avatar
Warren Dukes committed
103

104
enum playlist_result playPlaylistById(int song, int stopOnError);
105

106
void nextSongInPlaylist(void);
Warren Dukes's avatar
Warren Dukes committed
107

108
void syncPlayerAndPlaylist(void);
Warren Dukes's avatar
Warren Dukes committed
109

110
void previousSongInPlaylist(void);
Warren Dukes's avatar
Warren Dukes committed
111

112
void shufflePlaylist(void);
Warren Dukes's avatar
Warren Dukes committed
113

114
enum playlist_result savePlaylist(const char *utf8file);
Warren Dukes's avatar
Warren Dukes committed
115

116 117
void
deleteASongFromPlaylist(const struct song *song);
Warren Dukes's avatar
Warren Dukes committed
118

119
enum playlist_result moveSongInPlaylist(unsigned from, int to);
Warren Dukes's avatar
Warren Dukes committed
120

121
enum playlist_result moveSongInPlaylistById(unsigned id, int to);
122

123
enum playlist_result swapSongsInPlaylist(unsigned song1, unsigned song2);
Warren Dukes's avatar
Warren Dukes committed
124

125
enum playlist_result swapSongsInPlaylistById(unsigned id1, unsigned id2);
126

127
enum playlist_result loadPlaylist(struct client *client, const char *utf8file);
Warren Dukes's avatar
Warren Dukes committed
128

129
bool getPlaylistRepeatStatus(void);
Warren Dukes's avatar
Warren Dukes committed
130

131
void setPlaylistRepeatStatus(bool status);
Warren Dukes's avatar
Warren Dukes committed
132

133
bool getPlaylistRandomStatus(void);
Warren Dukes's avatar
Warren Dukes committed
134

135
void setPlaylistRandomStatus(bool status);
Warren Dukes's avatar
Warren Dukes committed
136

137
int getPlaylistCurrentSong(void);
Warren Dukes's avatar
Warren Dukes committed
138

139
unsigned getPlaylistSongId(unsigned song);
140

141
int getPlaylistLength(void);
Warren Dukes's avatar
Warren Dukes committed
142

143
unsigned long getPlaylistVersion(void);
Warren Dukes's avatar
Warren Dukes committed
144

145
void playPlaylistIfPlayerStopped(void);
Warren Dukes's avatar
Warren Dukes committed
146

147
enum playlist_result seekSongInPlaylist(unsigned song, float seek_time);
Warren Dukes's avatar
Warren Dukes committed
148

149
enum playlist_result seekSongInPlaylistById(unsigned id, float seek_time);
150

151
void playlistVersionChange(void);
152

153
int playlistChanges(struct client *client, uint32_t version);
154

155
int playlistChangesPosId(struct client *client, uint32_t version);
156

157
int PlaylistInfo(struct client *client, const char *utf8file, int detail);
158

159
void searchForSongsInPlaylist(struct client *client,
160
			      unsigned numItems, LocateTagItem * items);
161

162
void findSongsInPlaylist(struct client *client,
163
			 unsigned numItems, LocateTagItem * items);
164

165 166
int is_valid_playlist_name(const char *utf8path);

Warren Dukes's avatar
Warren Dukes committed
167
#endif