summaryrefslogtreecommitdiffstats
path: root/src/player.h
blob: e2c5fafd7df0a28426b53b060e08792ba0f19bd0 (plain) (blame)
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
#pragma once

#include "list.h"
#include "util.h"

enum {
	PLAYER_STATUS_OK,
	PLAYER_STATUS_ERR
};

enum {
	PLAYER_STATUS_MSG_NONE,
	PLAYER_STATUS_MSG_INFO,
	PLAYER_STATUS_MSG_ERR
};

enum {
	PLAYER_STATE_NONE,
	PLAYER_STATE_PAUSED,
	PLAYER_STATE_PLAYING,
	PLAYER_STATE_STOPPED
};

struct player {
	/* list of tracks to choose from on prev / next */
	struct list playlist; /* struct track (link_pl) */

	/* played track history */
	struct list history;  /* struct track (link_hs) */

	/* queued tracks */
	struct list queue; /* struct track (link_pq) */

	/* last used track */
	struct track *track;

	/* player track name (not necessarily from player.track) */
	char *track_name;

	/* player has a track is loaded (not necessarily player.track) */
	bool loaded;

	/* automatically select new tracks when queue empty */
	bool autoplay;

	/* randomize which track is chosen when queue empty */
	bool shuffle;

	/* stopped, paused or playing */
	int state;

	/* volume adjustment when possible */
	int volume;

	/* track position and duration */
	unsigned int time_pos, time_end;

	/* status messaging */
	char *status;
	int status_lvl;
};

void player_init(void);
void player_deinit(void);

void player_update(void);

int player_play_track(struct track *track, bool new);
int player_clear_track(void);

int player_toggle_pause(void);
int player_pause(void);
int player_resume(void);
int player_prev(void);
int player_next(void);
int player_seek(int sec);
int player_play(void);
int player_stop(void);

int player_set_volume(unsigned int vol);

extern struct player player;