Subversion Repositories Kolibri OS

Rev

Rev 7182 | Rev 7188 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7182 Rev 7183
Line 11... Line 11...
11
//===================================================//
11
//===================================================//
Line 12... Line 12...
12
 
12
 
13
#include "../lib/file_system.h"
13
#include "../lib/file_system.h"
14
#include "../lib/list_box.h"
14
#include "../lib/list_box.h"
-
 
15
#include "../lib/gui.h"
15
#include "../lib/gui.h"
16
#include "../lib/random.h"
16
#include "../lib/kfont.h"
17
#include "../lib/kfont.h"
Line 17... Line 18...
17
#include "../lib/collection.h"
18
#include "../lib/collection.h"
18
 
19
 
Line 33... Line 34...
33
 
34
 
34
//simple open dialog data
35
//simple open dialog data
35
char default_dir[] = "/rd/1";
36
char default_dir[] = "/rd/1";
Line 36... Line 37...
36
od_filter filter2 = { 8, "MP3\0\0" };
37
od_filter filter2 = { 8, "MP3\0\0" };
37
 
38
 
Line 38... Line 39...
38
#define ABOUT_MESSAGE "'Pixies Player v2.5
39
#define ABOUT_MESSAGE "'Pixies Player v2.6
39
A tiny MP3 folder player.
40
A tiny MP3 folder player.
40
 
41
 
Line 60... Line 61...
60
	BUTTON_WINDOW_MINIMIZE,
61
	BUTTON_WINDOW_MINIMIZE,
61
	BUTTON_WINDOW_REDUCE,
62
	BUTTON_WINDOW_REDUCE,
62
	BUTTON_PLAYBACK_PLAY_PAUSE = 10,
63
	BUTTON_PLAYBACK_PLAY_PAUSE = 10,
63
	BUTTON_PLAYBACK_PREV, 
64
	BUTTON_PLAYBACK_PREV, 
64
	BUTTON_PLAYBACK_NEXT,
65
	BUTTON_PLAYBACK_NEXT,
-
 
66
	BUTTON_REPEAT,
-
 
67
	BUTTON_SHUFFLE,
65
	BUTTON_OPEN_DIALOG,
68
	BUTTON_OPEN_DIALOG,
66
	BUTTON_SHOW_VOLUME
69
	BUTTON_SHOW_VOLUME
67
};
70
};
Line 68... Line 71...
68
 
71
 
69
int player_run_id;
72
int player_run_id;
Line -... Line 73...
-
 
73
int notify_run_id;
-
 
74
 
-
 
75
bool repeat;
70
int notify_run_id;
76
bool shuffle;
Line 71... Line 77...
71
 
77
 
72
int current_playing_file_n=0;
78
int current_playing_file_n=0;
Line 110... Line 116...
110
void main()
116
void main()
111
{
117
{
112
	int tempstr;
118
	int tempstr;
113
	tempstr = abspath("pixie.ini");
119
	tempstr = abspath("pixie.ini");
114
	strcpy(#pixie_ini_path, tempstr);
120
	strcpy(#pixie_ini_path, tempstr);
115
	list.SetFont(8, 14, 0x90);
121
	list.SetFont(8, 16, 13);
116
	if (!param) notify("'Pixie Player\nPress O key to open MP3 file' -St");
122
	if (!param) notify("'Pixie Player\nPress O key to open MP3 file' -St");
117
	LoadLibraries();
123
	LoadLibraries();
118
	LoadIniConfig();
124
	LoadIniConfig();
119
	kfont.init(DEFAULT_FONT);	
125
	kfont.init(DEFAULT_FONT);	
120
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
126
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
Line 147... Line 153...
147
				case BUTTON_WINDOW_MINIMIZE: MinimizeWindow(); break;
153
				case BUTTON_WINDOW_MINIMIZE: MinimizeWindow(); break;
148
				case BUTTON_WINDOW_REDUCE: EventChangeWindowMode(); break;
154
				case BUTTON_WINDOW_REDUCE: EventChangeWindowMode(); break;
149
				case BUTTON_PLAYBACK_PREV: EventPlaybackPrevious();	break;
155
				case BUTTON_PLAYBACK_PREV: EventPlaybackPrevious();	break;
150
				case BUTTON_PLAYBACK_NEXT: EventPlaybackNext(); break;
156
				case BUTTON_PLAYBACK_NEXT: EventPlaybackNext(); break;
151
				case BUTTON_PLAYBACK_PLAY_PAUSE: EventPlayAndPause(); break;
157
				case BUTTON_PLAYBACK_PLAY_PAUSE: EventPlayAndPause(); break;
-
 
158
				case BUTTON_REPEAT: EventRepeatClick(); break;
-
 
159
				case BUTTON_SHUFFLE: EventshuffleClick(); break;
152
				case BUTTON_OPEN_DIALOG: EventFileDialogOpen(); break;
160
				case BUTTON_OPEN_DIALOG: EventFileDialogOpen(); break;
153
				case BUTTON_SHOW_VOLUME: RunProgram("/sys/@VOLUME", NULL); break;
161
				case BUTTON_SHOW_VOLUME: RunProgram("/sys/@VOLUME", NULL); break;
154
			}
162
			}
155
			break;	  
163
			break;	  
156
		case evKey:
164
		case evKey:
Line 216... Line 224...
216
		if (i + list.first == current_playing_file_n) && (playback_mode == PLAYBACK_MODE_PLAYING)
224
		if (i + list.first == current_playing_file_n) && (playback_mode == PLAYBACK_MODE_PLAYING)
217
		{
225
		{
218
			text_color = theme.color_list_active_text;
226
			text_color = theme.color_list_active_text;
219
		}
227
		}
220
		DrawBar(list.x, yyy, list.w, list.item_h, bg_color);
228
		DrawBar(list.x, yyy, list.w, list.item_h, bg_color);
221
		kfont.WriteIntoWindow(12, yyy+list.text_y, bg_color, text_color, 11, #temp_filename);
229
		kfont.WriteIntoWindow(6, yyy+list.text_y, bg_color, text_color, list.font_type, #temp_filename);
222
	}
230
	}
223
	DrawBar(list.x,list.visible * list.item_h + list.y, list.w, -list.visible * list.item_h + list.h, theme.color_list_bg);
231
	DrawBar(list.x,list.visible * list.item_h + list.y, list.w, -list.visible * list.item_h + list.h, theme.color_list_bg);
224
	DrawScroller();
232
	DrawScroller();
225
}
233
}
Line 253... Line 261...
253
	//Mode depended
261
	//Mode depended
254
	if (window_mode == WINDOW_MODE_NORMAL)
262
	if (window_mode == WINDOW_MODE_NORMAL)
255
	{
263
	{
256
		button_y = 46;
264
		button_y = 46;
257
		img_draw stdcall(skin.image, 0, 0, skin.w, skin.h, 0, 0);
265
		img_draw stdcall(skin.image, 0, 0, skin.w, skin.h, 0, 0);
258
		if (playback_mode != PLAYBACK_MODE_STOPED) img_draw stdcall(skin.image, 40, button_y, 35, 19, skin.w+1, WIN_H_SMALL+1);
266
		if (playback_mode != PLAYBACK_MODE_STOPED) img_draw stdcall(skin.image, 46, button_y, 41, 21, skin.w+1, WIN_H_SMALL+1);
-
 
267
		if (repeat) img_draw stdcall(skin.image, Form.width - 108+8, button_y, 20, 20, skin.w+50, WIN_H_SMALL+1);
-
 
268
		if (shuffle) img_draw stdcall(skin.image, Form.width - 81+5, button_y, 20, 20, skin.w+75, WIN_H_SMALL+1);
-
 
269
 
259
		if /*(!list.count) && */ (!work_folder) DrawPixieTitle("Pixie");
270
		if /*(!list.count) && */ (!work_folder) DrawPixieTitle("Pixie");
260
		else DrawPixieTitle(#work_folder + strrchr(#work_folder, '/'));
271
		else DrawPixieTitle(#work_folder + strrchr(#work_folder, '/'));
261
		kfont.WriteIntoWindow(10, 26, theme.color_top_panel_bg, theme.color_top_panel_song_name, 11, GetSongTitle());
272
		kfont.WriteIntoWindow(8, 24, theme.color_top_panel_bg, theme.color_top_panel_song_name, list.font_type, GetSongTitle());
262
	 	//Playing control buttons
273
	 	//Playing control buttons
263
		DefineHiddenButton(7, button_y, 32, 18, BUTTON_PLAYBACK_PREV);
274
		DefineHiddenButton(7, button_y, 38, 20, BUTTON_PLAYBACK_PREV);
264
		DefineHiddenButton(41, button_y, 32, 18, BUTTON_PLAYBACK_PLAY_PAUSE);
275
		DefineHiddenButton(47, button_y, 38, 20, BUTTON_PLAYBACK_PLAY_PAUSE);
265
		DefineHiddenButton(75, button_y, 32, 18, BUTTON_PLAYBACK_NEXT);
276
		DefineHiddenButton(87, button_y, 38, 20, BUTTON_PLAYBACK_NEXT);
266
		//Window control buttons
277
		//Window control buttons
267
		DefineHiddenButton(Form.width - 21, 1, 20, 13, BUTTON_WINDOW_CLOSE);
278
		DefineHiddenButton(Form.width - 27, 1, 26, 15, BUTTON_WINDOW_CLOSE);
268
		DefineHiddenButton(Form.width - 43, 1, 20, 13, BUTTON_WINDOW_MINIMIZE);
279
		DefineHiddenButton(Form.width - 55, 1, 26, 15, BUTTON_WINDOW_MINIMIZE);
269
		DefineHiddenButton(Form.width - 65, 1, 20, 13, BUTTON_WINDOW_REDUCE);
280
		DefineHiddenButton(Form.width - 83, 1, 26, 15, BUTTON_WINDOW_REDUCE);
270
		//Open and volume
281
		//Other buttons
-
 
282
		DefineHiddenButton(Form.width - 108,button_y, 23, 23, BUTTON_REPEAT);
-
 
283
		DefineHiddenButton(Form.width - 81, button_y, 23, 23, BUTTON_SHUFFLE);
271
		DefineHiddenButton(Form.width - 56, button_y, 23, 23, BUTTON_OPEN_DIALOG);
284
		DefineHiddenButton(Form.width - 54, button_y, 23, 23, BUTTON_OPEN_DIALOG);
272
		DefineHiddenButton(Form.width - 27, button_y, 23, 23, BUTTON_SHOW_VOLUME);
285
		DefineHiddenButton(Form.width - 27, button_y, 23, 23, BUTTON_SHOW_VOLUME);
273
	}
286
	}
274
	else if (window_mode == WINDOW_MODE_SMALL)
287
	else if (window_mode == WINDOW_MODE_SMALL)
275
	{
288
	{
276
		button_y = 7;
289
		button_y = 7;
Line 299... Line 312...
299
	if (list.count > list.visible) scrollbar_v_draw(#scroll1);
312
	if (list.count > list.visible) scrollbar_v_draw(#scroll1);
300
}
313
}
Line 301... Line 314...
301
 
314
 
302
void DrawPixieTitle(dword _title)
315
void DrawPixieTitle(dword _title)
303
{
-
 
304
	kfont.bold = true;
316
{
305
	kfont.WriteIntoWindow(10, 6, theme.color_top_panel_bg, theme.color_top_panel_folder_name, 12, _title);
-
 
306
	kfont.bold = false;
317
	kfont.WriteIntoWindow(8, 5, theme.color_top_panel_bg, theme.color_top_panel_folder_name, list.font_type, _title);
Line 307... Line 318...
307
}
318
}
308
 
319
 
309
//===================================================//
320
//===================================================//
Line 370... Line 381...
370
	sprintf(#item_path,"-h %s/%s",#work_folder,#current_filename);
381
	sprintf(#item_path,"-h %s/%s",#work_folder,#current_filename);
371
	DrawPlayList();
382
	DrawPlayList();
372
	DrawTopPanel();
383
	DrawTopPanel();
373
	player_run_id = RunProgram("/sys/media/ac97snd", #item_path);	
384
	player_run_id = RunProgram("/sys/media/ac97snd", #item_path);	
374
	sprintf(#notify_message,"'Now playing:\n%s' -St",#current_filename);
385
	sprintf(#notify_message,"'Now playing:\n%s' -St",#current_filename);
-
 
386
	if (!repeat)
-
 
387
	{
-
 
388
		for (i=2; i
375
	for (i=2; i
389
			if (notify_message[i]=='\'') notify_message[i]=96; //replace ' char to avoid @notify misunderstood
376
	notify_run_id = notify(#notify_message);
390
		notify_run_id = notify(#notify_message);
377
}
391
	}
-
 
392
}
Line 378... Line 393...
378
 
393
 
379
 
394
 
380
void EventPlayAndPause() 
395
void EventPlayAndPause() 
Line 419... Line 434...
419
	ExitProcess();
434
	ExitProcess();
420
}
435
}
Line 421... Line 436...
421
 
436
 
422
void EventPlaybackPrevious()
437
void EventPlaybackPrevious()
-
 
438
{
423
{
439
	if (shuffle) current_playing_file_n = random(list.count);
424
	current_playing_file_n--;
440
	else current_playing_file_n--;
425
	EventStartPlayingMp3();
441
	EventStartPlayingMp3();
Line 426... Line 442...
426
}
442
}
427
 
443
 
-
 
444
void EventPlaybackNext()
428
void EventPlaybackNext()
445
{
429
{
446
	if (shuffle) current_playing_file_n = random(list.count);
430
	current_playing_file_n++;
447
	else current_playing_file_n++;
Line 431... Line 448...
431
	EventStartPlayingMp3();
448
	EventStartPlayingMp3();
432
}
449
}
Line 444... Line 461...
444
}
461
}
Line 445... Line 462...
445
 
462
 
446
void EventCheckSongFinished()
463
void EventCheckSongFinished()
447
{
464
{
-
 
465
	if (playback_mode == PLAYBACK_MODE_PLAYING) && (!GetProcessSlot(player_run_id)) {
448
	if (playback_mode == PLAYBACK_MODE_PLAYING) && (!GetProcessSlot(player_run_id)) {
466
		if (repeat) EventStartPlayingMp3();
449
		EventPlaybackNext();
467
		else EventPlaybackNext();
450
	}
468
	}
Line -... Line 469...
-
 
469
}
-
 
470
 
-
 
471
void EventRepeatClick()
-
 
472
{
-
 
473
	repeat ^= 1;
-
 
474
	DrawTopPanel();
-
 
475
}
-
 
476
 
-
 
477
void EventshuffleClick()
-
 
478
{
-
 
479
	shuffle ^= 1;
Line 451... Line 480...
451
}
480
	DrawTopPanel();
Line 452... Line 481...
452
 
481
}
453
 
482