summaryrefslogtreecommitdiff
path: root/playlist.h
blob: 2a1501ae01fc3f145ca7f9e4de6ae6fffe5c26ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
    DeaDBeeF - ultimate music player for GNU/Linux systems with X11
    Copyright (C) 2009  Alexey Yakovenko

    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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef __PLAYLIST_H
#define __PLAYLIST_H

typedef struct metaInfo_s {
    const char *key;
    char *value;
    struct metaInfo_s *next;
} metaInfo_t;

typedef struct playItem_s {
    char *fname; // full pathname
    struct codec_s *codec; // codec to use with this file
    int tracknum; // used for stuff like sid, nsf, cue (will be ignored by most codecs)
    float timestart; // start time of cue track, or -1
    float timeend; // end time of cue track, or -1
    float duration; // in seconds
    const char *filetype; // e.g. MP3 or OGG
    struct playItem_s *next; // next item in linked list
    struct playItem_s *prev; // prev item in linked list
    struct playItem_s *shufflenext; // next item in shuffle list
    struct metaInfo_s *meta; // linked list storing metainfo
    unsigned selected : 1;
} playItem_t;

extern playItem_t *playlist_head; // head of linked list
extern playItem_t *playlist_tail; // tail of linked list
extern playItem_t *playlist_shuffle_head; // head of shuffled playlist
extern playItem_t *playlist_current_ptr; // pointer to a real current playlist item
extern playItem_t playlist_current; // copy of playlist item being played (stays in memory even if removed from playlist)

int
ps_add_dir (const char *dirname, int (*cb)(playItem_t *it, void *data), void *user_data);

int
ps_add_file (const char *fname, int (*cb)(playItem_t *it, void *data), void *user_data);

playItem_t *
ps_insert_dir (playItem_t *after, const char *dirname, int (*cb)(playItem_t *it, void *data), void *user_data);

playItem_t *
ps_insert_file (playItem_t *after, const char *fname, int (*cb)(playItem_t *it, void *data), void *user_data);

playItem_t *
ps_insert_item (playItem_t *after, playItem_t *it);

int
ps_append_item (playItem_t *it);

int
ps_remove (playItem_t *i);

void
ps_item_free (playItem_t *it);

void
ps_free (void);

int
ps_getcount (void);

int
ps_getselcount (void);

playItem_t *
ps_get_for_idx (int idx);

int
ps_get_idx_of (playItem_t *it);

playItem_t *
ps_insert_cue (playItem_t *after, const char *cuename, const char *ftype);

int
ps_set_current (playItem_t *it);

// returns -1 if theres no next song, or playlist finished
// reason 0 means "song finished", 1 means "user clicked next"
int
ps_nextsong (int reason);

int
ps_prevsong (void);

int
ps_randomsong (void);

// starts current playlist item from position 0
// only if the item is still in playlist
void
ps_start_current (void);

void
ps_add_meta (playItem_t *it, const char *key, const char *value);

void
ps_format_item_display_name (playItem_t *it, char *str, int len);

const char *
ps_find_meta (playItem_t *it, const char *key);

void
ps_delete_selected (void);

void
ps_shuffle (void);

void
ps_set_order (int order);

void
ps_set_loop_mode (int mode);

#endif // __PLAYLIST_H