tmus

TUI Music Player
git clone https://git.sinitax.com/sinitax/tmus
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

player.h (1757B)


      1#pragma once
      2
      3#include "list.h"
      4#include "util.h"
      5
      6#define PLAYER_STATUS(...) do { \
      7		free(user_status); \
      8		user_status = aprintf("Player: " __VA_ARGS__); \
      9		user_status_uptime = 20; \
     10	} while (0)
     11
     12enum {
     13	PLAYER_OK,
     14	PLAYER_ERR
     15};
     16
     17enum {
     18	PLAYER_STATUS_MSG_NONE,
     19	PLAYER_STATUS_MSG_INFO,
     20	PLAYER_STATUS_MSG_ERR
     21};
     22
     23enum {
     24	PLAYER_STATE_NONE,
     25	PLAYER_STATE_PAUSED,
     26	PLAYER_STATE_PLAYING,
     27	PLAYER_STATE_STOPPED
     28};
     29
     30struct player {
     31	/* list of tracks to choose from on prev / next */
     32	struct list playlist; /* struct track (link_pl) */
     33
     34	/* played track history */
     35	struct list history;  /* struct track (link_hs) */
     36
     37	/* queued tracks */
     38	struct list queue; /* struct track (link_pq) */
     39
     40	/* last used track */
     41	struct track *track;
     42
     43	/* player track name (not necessarily from player.track) */
     44	char *track_name;
     45
     46	/* player has a track is loaded (not necessarily player.track) */
     47	bool loaded;
     48
     49	/* automatically select new tracks when queue empty */
     50	bool autoplay;
     51
     52	/* randomize which track is chosen when queue empty */
     53	bool shuffle;
     54
     55	/* stopped, paused or playing */
     56	int state;
     57
     58	/* volume adjustment when possible */
     59	int volume;
     60
     61	/* track position and duration */
     62	unsigned int time_pos, time_end;
     63
     64	/* status messaging */
     65	char *status;
     66	int status_lvl;
     67};
     68
     69void player_init(void);
     70void player_deinit(void);
     71
     72void player_update(void);
     73
     74int player_play_track(struct track *track, bool new);
     75int player_clear_track(void);
     76
     77void player_add_history(struct track *track);
     78
     79int player_toggle_pause(void);
     80int player_pause(void);
     81int player_resume(void);
     82int player_prev(void);
     83int player_next(void);
     84int player_seek(int sec);
     85int player_play(void);
     86int player_stop(void);
     87
     88int player_set_volume(unsigned int vol);
     89
     90extern struct player player;
     91