summaryrefslogtreecommitdiff
path: root/vdr_player.h
blob: 42a35d48f29341dcd6b7e6ab4089736557d55bef (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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
/*!								-*- c++ -*-
 * \file vdr_player.h
 * \brief A player/control combination to let VDR play music
 *
 * \version $Revision: 1.2 $
 * \date    $Date$
 * \author  Ralf Klueber, Lars von Wedel, Andreas Kellner
 * \author  Responsible author: $Author$
 *
 * $Id$
 *
 * Adapted from
 * MP3/MPlayer plugin to VDR (C++)
 * (C) 2001,2002 Stefan Huelswitt <huels@iname.com>
 * 
 * and from the Music plugin (c) Morone
 */

#ifndef ___VDR_PLAYER_H
#define ___VDR_PLAYER_H

#include <vdr/player.h>
#include "mg_selection.h"
#include "mg_item_gd.h"
#include "mg_playcommands.h"

#if VDRVERSNUM >= 10307
class cOsd;
#endif

extern char coverpicture[256];
// -------------------------------------------------------------------

class mgPCMPlayer;
class mgImageProvider;

// -------------------------------------------------------------------

class mgPlayerOsdListItem;
/*!
 *  \brief exerts control over the player itself
 *
 *  This control is launched from the main menu and manages a link
 *  to the player. Key events are caught and signaled to the player.
 */
class mgPlayerControl:public cControl, cStatus
{
	private:

		//! \brief the reference to the player
		mgPCMPlayer * player;

		// copied from music plugin, mp3control.h:
		cOsd *osd;
		string imagefile;
		string _message;
		int fw, fh;
		//

		mgPlayOsd *cmdOsd;
		mgPlayerCommands *cmdMenu;

		bool shown, statusActive, refresh, flush, skiprew, skipfwd;
		time_t timeoutShow, greentime, oktime;
		time_t messagetime;
		int num, number;
		int lastkeytime, playstatus, timecount;
		bool selecting, selecthide, artistfirst;
		//
		mgItemGd * currItem;
		mgItemGd * prevItem;
		unsigned int currPos;
		unsigned int prevPos;
		bool orderchanged;
		time_t fliptime, listtime;
		time_t flushtime;
		int rows;
		int flip, flipint, osdwidth, osdheight, lh, showbuttons;
		int x0, x1, coverdepth, listdepth,CoverX, CoverWidth, TopHeight,BottomTop,PBTop,PBHeight,PBBottom;
		int InfoTop,InfoWidth,InfoBottom;
		int lastIndex, lastTotal, prevTop, prevScrollPosition;
		int framesPerSecond;

		int ScrollPosition;

		//
		bool jumpactive, jumphide, jumpsecs;
		int jumpmm, channelsSA, bandsSA, visualization;
		//
		static cBitmap bmShutdown , bmShuffle , bmLoop , bmLoopAll, bmStop , bmPlay , bmPause , bmRew , bmFwd , bmCopy;

		static cBitmap bmDelStar,bmRate00,bmRate05,bmRate10,bmRate15,bmRate20,bmRate25,bmRate30,bmRate35,bmRate40,bmRate45,bmRate50;

		// , bmRec;
		//
		int clrTopBG1;
		int clrTopTextFG1;
		int clrTopBG2;
		int clrTopTextFG2;
		int clrTopItemBG1;
		int clrTopItemInactiveFG;
		int clrTopItemActiveFG;
		int clrListBG1;
		int clrListBG2;
		int clrListTextFG;
		int clrListTextActiveFG;
		int clrListTextActiveBG;
		int clrInfoBG1;
		int clrInfoBG2;
		int clrInfoTextFG1;
		int clrInfoTitleFG1;
		int clrInfoTextFG2;
		int clrProgressBG1;
		int clrProgressBG2;
		int clrProgressbarFG;
		int clrProgressbarBG;
		int clrStatusBG;
		int clrStatusRed;
		int clrStatusGreen;
		int clrStatusYellow;
		int clrStatusBlue;
		int clrStatusTextFG;
		int imgalpha;
		int mpgdif;
		bool layout_initialized;
		//
		void InitLayout(void);
		void ShowList(void);
		void ShowTimed(int Seconds=0);
		void ShowStatus(bool force);
		void HideStatus(void);
		void HidePlayOsd(void);
		void ShowHelpButtons(int ShowButtons);
		void ShowProgress(bool open=false);
		void Display();
		void DisplayInfo(const char *s=0);
		void JumpDisplay(void);
		void JumpProcess(eKeys Key);
		void Jump(void);
		void LoadCover(void);
		void CopyTrack(void);
		inline void Flush(void);
		void ShutDown(void);
		int CurrentVolume(void);
		bool LoadImage(const char* fullname,bool coveronly);
		char Songname[256];
		bool CoverChanged();
		mgSelection *PlayList(void);
		string TrackInfo(const mgItemGd* item);
		const cFont * OsdFont(void);
		const cFont * BigFont(void);
		const cFont * SmallFont(void);
		void DumpAreas(const char *caller,const tArea *Areas, int NumAreas,eOsdError err);
		bool SetAreas(const char *caller,const tArea *Areas, int NumAreas);
		tArea * ProgressAreas(int& NumAreas);
		void Scroll(int by);
		void ShowCommandMenu();

		const char ShuffleChar();
		const char LoopChar();

		//! \brief the image provider
		mgImageProvider *m_img_provider;
		void CheckImage( );
		void TransferImageTFT( string cover );
		// background image handling stuff
		int m_lastshow;
		string m_current_image;
		string m_current_imagesource;
		time_t m_imageshowtime;
		string oneartist;

		vector<mgPlayerOsdListItem*> pl;

	public:

		mgItemGd * CurrentItem(void);

		/*! \brief construct a control with a playlist
		 *
		 *  \param plist - the playlist to be played
		 */
		mgPlayerControl (mgSelection * plist);

		/*! \brief destructor
		 */
		virtual ~ mgPlayerControl ();

		//! \brief indicate whether the corresponding player is active
		bool Active ();

		//! \brief indicate whether the corresponding player is playing
		bool Playing ();

		//! \brief stop the corresponding player
		void Stop ();

		//! \brief toggle the pause mode of the corresponding player
		void Pause ();

		//! \brief start playing
		void Play ();

		//! \brief skip to the next song
		void Forward ();

		//! \brief skip to the previous song
		void Backward ();

		/*! \brief skip a specified number of seconds
		 *
		 *  \param seconds - the number of seconds to skip
		 */
		void SkipSeconds (int seconds);

		/*! \brief goto a certain position in the playlist
		 *
		 *  \param index - the position in the playlist to skip to
		 */
		void Goto (int index);

		//! \brief toggle the shuffle mode of the corresponding player
		void ToggleShuffle ();

		//! \brief toggle the loop mode of the corresponding player
		void ToggleLoop ();

		/*! \brief tell the player to reload the play list.
		 * This is needed if we play a collection
		 * and the user changed the collection while playing it
		 */
		void ReloadPlaylist();

		/*! \brief signal a new playlist
		 *
		 *  The caller has to take care of deallocating the previous list
		 *
		 *  \param plist - the new playlist to be played
		 */
		void NewPlaylist (mgSelection * plist);

		/*! \brief signal a new image playlist
		 *
		 *  A directory is passed and all images (.jpg, .png) contained in this dir are to be displayed during playback.
		 *
		 *  \param directory - the directory containing images to be replayed
		 */
		void NewImagePlaylist (const char *directory);


		//! \brief a progress display
		void ShowContents ();

		//! \brief hide the osd, if present
		void Hide ();

		//! \brief process key events
		eOSState ProcessKey (eKeys key);

		eOSState ProcessPlayerKey(eKeys Key);

};
#endif							 //___VDR_PLAYER_H