File: mpd.h

package info (click to toggle)
mpdas 0.4.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 188 kB
  • sloc: cpp: 1,455; makefile: 34
file content (55 lines) | stat: -rw-r--r-- 1,098 bytes parent folder | download
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
#ifndef _MPD_H
#define _MPD_H

class Song {
public:
	Song() {};
	Song(struct mpd_song *song);
	Song(std::string artist, std::string title, std::string album, int duration) {
		this->artist = artist;
		this->title = title;
		this->album = album;
		this->duration = duration;
	}

	std::string getArtist() const { return artist; }
	std::string getTitle() const { return title; }
	std::string getAlbum() const { return album; }
	std::string getAlbumArtist() const { return albumartist; }
	int getDuration() const { return duration; }
private:
	std::string albumartist, artist, title, album;
	int duration;
};

class CMPD
{
public:
	CMPD(CConfig *cfg);
	~CMPD();

	bool Connect();
	void Update();
	void SetSong(const Song *song);
	void CheckSubmit(int curplaytime);
	Song GetSong() const { return _song; };

	inline bool isConnected() { return _connected; }
private:
	void GotNewSong(struct mpd_song *song);

	CConfig *_cfg;
	mpd_connection *_conn;
	int _songid;
	int _songpos;
	Song _song;
	bool _gotsong;
	int _start;
	time_t _starttime;
	bool _connected;
	bool _cached;
};

extern CMPD* MPD;

#endif