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
32
33
37
38
39
42
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
157
158
159
160
161
162
163
164
165
190
215
216
217
222
223
224
225
226
227
228
229
230
234
238
239
240
245
246
247
248
249
250
251
252
253
257
261
262
263
268
269
270
271
272
273
274
275
276
280
284
285
286
291
292
293
294
295
296
297
298
299
303
307
308
309
314
315
316
317
318
319
320
321
322
326
330
331
332
337
338
339
340
341
342
343
344
345
349
353
354
355
360
361
362
363
364
365
369
373
377
378
379
384
385
386
387
388
389
393
397
398
399
404
415
416
421
432
433
438
449
450
455
466
467
472
483
484
489
500
501
506
517
518
523
534
535
540
551
552
557
558
559
560
561
562
563
564
565
566
567
568
569
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
605
606
607
616
618
619
620
621
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
649
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
732
733
734
735
736
737
738
739
740
741
742
743
748
749
750
751
752
753
754
771
778
779
780
781
782
787
807
808
813
834
835
840
841
842
843
844
845
846
847
848
849
855
856
857
858
859
860
861
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
884
885
886
887
888
889
890
891
892
893
894
895
896
904
906
907
908
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1099
1100
1101
1102
1103
1104
1108
1112
1116
1117
1118
1119
1120
1139
1140
1141
1142
1143
1144
1145
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1280
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1321
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1354
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1383
1384
1385
1386
1387
1388
1389
1390
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1457
1458
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1502
1503
/* ... */
#include "DIALOG.h"
#include "k_module.h"
#include "audioplayer_app.h"
#include "audioplayer_res.c"
#include "k_modules_res.h"
#include "k_storage.h"
#include "k_rtc.h"
#include "k_mem.h"
#include "../Modules/filebrowser/filebrowser_app.h"
9 includes
/* ... */
/* ... */
Includes
static void Startup(WM_HWIN hWin, uint16_t xpos, uint16_t ypos);
static void AudioDirectOpen(char *filename);Private function prototypes
K_ModuleItem_Typedef audio_player =
{
8,
"Audio Player",
&bmaudioplayer,
Startup,
AudioDirectOpen,
...};
typedef union
{
uint32_t d32;
struct
{
uint32_t repeat : 2;
uint32_t pause : 2;
uint32_t mute : 1;
uint32_t volume : 8;
uint32_t reserved : 21;
...}b;
...}
AudioSettingsTypeDef;Private typedef
#define REPEAT_NONE 0
#define REPEAT_ONCE 1
#define REPEAT_ALL 2
#define ID_PROCESS_TIMER 1
#define ID_PLAYLIST_TIMER 2
#define ID_FRAMEWIN_INFO (GUI_ID_USER + 0x01)
#define ID_WAVFILE_LIST (GUI_ID_USER + 0x10)
#define ID_REPEAT_BUTTON (GUI_ID_USER + 0x20)
#define ID_CLOSE_BUTTON (GUI_ID_USER + 0x21)
#define ID_MUTE_BUTTON (GUI_ID_USER + 0x22)
#define ID_PREVIOUS_BUTTON (GUI_ID_USER + 0x23)
#define ID_PLAY_BUTTON (GUI_ID_USER + 0x24)
#define ID_NEXT_BUTTON (GUI_ID_USER + 0x25)
#define ID_STOP_BUTTON (GUI_ID_USER + 0x27)
#define ID_PAUSE_BUTTON (GUI_ID_USER + 0x28)
#define ID_WAV_BUTTON (GUI_ID_USER + 0x29)
#define ID_PLAY_LIST_BUTTON (GUI_ID_USER + 0x2A)
#define ID_ADD_BUTTON (GUI_ID_USER + 0x2B)
#define ID_VOLUME_SLIDER (GUI_ID_USER + 0x30)
#define ID_DURATION_SLIDER (GUI_ID_USER + 0x31)
#define ID_TITLE_CAPTION (GUI_ID_USER + 0x40)
#define ID_TITLE (GUI_ID_USER + 0x41)
#define ID_ELAPSED_TIME (GUI_ID_USER + 0x42)
#define ID_AUTHOR_CAPTION (GUI_ID_USER + 0x43)
#define ID_AUTHOR (GUI_ID_USER + 0x44)
#define ID_SAMPLING_CAPTION (GUI_ID_USER + 0x52)
#define ID_SAMPLING_VALUE (GUI_ID_USER + 0x53)
#define ID_TOTAL_TIME (GUI_ID_USER + 0x54)
#define ID_FRAMEWIN_0 (GUI_ID_USER + 0x60)
#define ID_MULTIPAGE (GUI_ID_USER + 0x61)
#define ID_RADIO_0 (GUI_ID_USER + 0x62)
#define ID_EDIT_71 (GUI_ID_USER + 0x63)
#define ID_EDIT_70 (GUI_ID_USER + 0x64)
#define ID_BUTTON_70 (GUI_ID_USER + 0x65)
#define ID_BUTTON_71 (GUI_ID_USER + 0x66)
#define ID_BUTTON_72 (GUI_ID_USER + 0x67)
#define ID_BUTTON_73 (GUI_ID_USER + 0x68)
37 defines
Private defines
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ WINDOW_CreateIndirect, "Audio Player", ID_FRAMEWIN_INFO, 0, 0, 640, 439, 0, 0x64, 0 },
{ LISTVIEW_CreateIndirect, "Listview", ID_WAVFILE_LIST, 280, 06, 350, 425, 0, 0x0, 0 },
{ SLIDER_CreateIndirect, "Slider", ID_VOLUME_SLIDER, 145, 155, 125, 20, 0, 0x0, 0 },
{ SLIDER_CreateIndirect, "Slider1", ID_DURATION_SLIDER, 15, 125, 255, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Title", ID_TITLE_CAPTION, 20, 10, 40, 30, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "", ID_TITLE, 60, 10, 150, 30, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Duration", ID_ELAPSED_TIME, 35, 217, 250, 250, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "AUTHOR", ID_AUTHOR_CAPTION, 20, 30, 60, 30, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "AUTHOR", ID_AUTHOR, 80, 30, 70, 30, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "samplingRate", ID_SAMPLING_CAPTION, 20, 50, 80, 30, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Value", ID_SAMPLING_VALUE, 100, 50, 70, 30, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Time", ID_TOTAL_TIME, 20, 70, 50, 30, 0, 0x0, 0 },
...};
static WM_HWIN AUDIOPLAYER_hWin;
static WM_HTIMER hProcessTimer;
static WM_HTIMER hPlaylistTimer;
static WM_HWIN hTimerWin;
static WAV_InfoTypedef WavInfo;
static FILELIST_FileTypeDef *pWavList;
static CHOOSEFILE_INFO *pFileInfo;
static char const *apDrives[2] = {"0:", "1:"};
static const char acMask_audio[] = ".audio";
static const char acMask_dir[] = ".dir";
static uint16_t file_pos = 0;
static AudioSettingsTypeDef PlayerSettings;
static uint8_t playlist_select = 0;Private variables
/* ... */
static void _OnPaint_play(BUTTON_Handle hObj) {
int Index;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
if(PlayerSettings.b.pause == PAUSE_ACTIVE)
{
GUI_DrawBitmap(&bmplay_pressed, 0, 0);
}if (PlayerSettings.b.pause == PAUSE_ACTIVE) { ... }
else if(PlayerSettings.b.pause == PLAY_ACTIVE)
{
GUI_DrawBitmap(&bmpause_pressed, 0, 0);
}else if (PlayerSettings.b.pause == PLAY_ACTIVE) { ... }
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
else if(AUDIOPLAYER_GetState() == AUDIOPLAYER_STOP)
{
if(PlayerSettings.b.pause == PLAY_ACTIVE)
{
GUI_DrawBitmap(&bmplay_pressed, 0, 0);
}if (PlayerSettings.b.pause == PLAY_ACTIVE) { ... }
else if(PlayerSettings.b.pause == PAUSE_ACTIVE)
{
GUI_DrawBitmap(&bmpause_pressed, 0, 0);
}else if (PlayerSettings.b.pause == PAUSE_ACTIVE) { ... }
}else if (AUDIOPLAYER_GetState() == AUDIOPLAYER_STOP) { ... }
}if (Index) { ... }
else
{
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
if(PlayerSettings.b.pause == PAUSE_ACTIVE)
{
GUI_DrawBitmap(&bmplay_not_pressed, 0, 0);
}if (PlayerSettings.b.pause == PAUSE_ACTIVE) { ... }
else if(PlayerSettings.b.pause == PLAY_ACTIVE)
{
GUI_DrawBitmap(&bmpause_not_pressed, 0, 0);
}else if (PlayerSettings.b.pause == PLAY_ACTIVE) { ... }
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
else if(AUDIOPLAYER_GetState() == AUDIOPLAYER_STOP)
{
if(PlayerSettings.b.pause == PLAY_ACTIVE)
{
GUI_DrawBitmap(&bmplay_not_pressed, 0, 0);
}if (PlayerSettings.b.pause == PLAY_ACTIVE) { ... }
else if(PlayerSettings.b.pause == PAUSE_ACTIVE)
{
GUI_DrawBitmap(&bmpause_not_pressed, 0, 0);
}else if (PlayerSettings.b.pause == PAUSE_ACTIVE) { ... }
}else if (AUDIOPLAYER_GetState() == AUDIOPLAYER_STOP) { ... }
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_stop(BUTTON_Handle hObj) {
int Index;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
GUI_DrawBitmap(&bmstop_pressed, 0, 0);
}if (Index) { ... }
else
{
GUI_DrawBitmap(&bmstop_not_pressed, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_previous(BUTTON_Handle hObj) {
int Index;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
GUI_DrawBitmap(&bmprevious_pressed, 0, 0);
}if (Index) { ... }
else
{
GUI_DrawBitmap(&bmprevious_not_pressed, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_next(BUTTON_Handle hObj) {
int Index;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
GUI_DrawBitmap(&bmnext_pressed, 0, 0);
}if (Index) { ... }
else
{
GUI_DrawBitmap(&bmnext_not_pressed, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_add(BUTTON_Handle hObj) {
int Index;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
GUI_DrawBitmap(&bmadd_pressed, 0, 0);
}if (Index) { ... }
else
{
GUI_DrawBitmap(&bmadd_not_pressed, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_open(BUTTON_Handle hObj) {
int Index;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
GUI_DrawBitmap(&bmopen_pressed, 0, 0);
}if (Index) { ... }
else
{
GUI_DrawBitmap(&bmopen_not_pressed, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_close(BUTTON_Handle hObj) {
int Index;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
GUI_DrawBitmap(&bmclose_pressed, 0, 0);
}if (Index) { ... }
else
{
GUI_DrawBitmap(&bmclose_not_pressed, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_repeat(uint32_t repeat_status) {
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
if(PlayerSettings.b.repeat == REPEAT_NONE)
{
GUI_DrawBitmap(&bmrepeat_off, 0, 0);
}if (PlayerSettings.b.repeat == REPEAT_NONE) { ... }
else if(PlayerSettings.b.repeat == REPEAT_ONCE)
{
GUI_DrawBitmap(&bmrepeat1, 0, 0);
}else if (PlayerSettings.b.repeat == REPEAT_ONCE) { ... }
else if(PlayerSettings.b.repeat == REPEAT_ALL)
{
GUI_DrawBitmap(&bmrepeat_all, 0, 0);
}else if (PlayerSettings.b.repeat == REPEAT_ALL) { ... }
}{ ... }
/* ... */
static void _OnPaint_speaker(uint32_t speaker_status) {
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
if(PlayerSettings.b.mute == MUTE_ON)
{
GUI_DrawBitmap(&bmspeaker_mute, 0, 0);
}if (PlayerSettings.b.mute == MUTE_ON) { ... }
else if(PlayerSettings.b.mute == MUTE_OFF)
{
GUI_DrawBitmap(&bmspeaker_not_mute, 0, 0);
}else if (PlayerSettings.b.mute == MUTE_OFF) { ... }
}{ ... }
/* ... */
static void _cbButton_play(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_play(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_stop(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_stop(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_next(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_next(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_previous(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_previous(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_add(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_add(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_open(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_open(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_close(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_close(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_repeat(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_repeat(PlayerSettings.b.repeat);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_speaker(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_speaker(PlayerSettings.b.mute);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbAudioProcess(WM_MESSAGE * pMsg) {
uint32_t Id;
WM_HWIN hItem;
char tmp[] = "00:00";
long progress;
uint32_t duration;
switch (pMsg->MsgId)
{
case WM_CREATE:
hProcessTimer = WM_CreateTimer(pMsg->hWin, ID_PROCESS_TIMER, 1000, 0);
break;
case WM_CREATE:
case WM_TIMER:
Id = WM_GetTimerId(pMsg->Data.v);
if(Id == ID_PROCESS_TIMER)
{
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
progress = AUDIOPLAYER_GetProgress();
duration = progress / WavInfo.ByteRate;
sprintf((char *)tmp , "%02lu:%02lu", duration/60, duration%60 );
hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_ELAPSED_TIME);
TEXT_SetText(hItem, tmp);
hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_DURATION_SLIDER);
progress = (long)(progress/(WavInfo.FileSize/100));
SLIDER_SetValue(hItem, progress);
WM_Update(hItem);
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
AUDIOPLAYER_Process();
WM_RestartTimer(pMsg->Data.v, 1000);
}if (Id == ID_PROCESS_TIMER) { ... }
else if (Id == ID_PLAYLIST_TIMER)
{
playlist_select = 0;
}else if (Id == ID_PLAYLIST_TIMER) { ... }
break;
case WM_TIMER:
case WM_DELETE:
WM_DeleteTimer(hProcessTimer);
if(hPlaylistTimer)
{
WM_DeleteTimer(hPlaylistTimer);
hPlaylistTimer = 0;
}if (hPlaylistTimer) { ... }
break;
case WM_DELETE:
default:
WM_DefaultProc(pMsg);default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _AddEntireFolder(char *Foldername)
{
FRESULT res;
uint32_t duration;
FILINFO fno;
DIR dir;
char *fn;
char tmp[FILEMGR_FULL_PATH_SIZE];
WM_HWIN hItem;
res = f_opendir(&dir, Foldername);
if (res == FR_OK)
{
while (1)
{
res = f_readdir(&dir, &fno);
if (res != FR_OK || fno.fname[0] == 0)
{
break;
}if (res != FR_OK || fno.fname[0] == 0) { ... }
if (fno.fname[0] == '.')
{
continue;
}if (fno.fname[0] == '.') { ... }
fn = fno.fname;
if (pWavList->ptr < FILEMGR_LIST_DEPDTH)
{
if ((fno.fattrib & AM_DIR) == 0)
{
if(((strstr(fn, ".wav")) || (strstr(fn, ".WAV"))) && (AUDIOPLAYER_hWin != 0))
{
strcpy(tmp, Foldername);
strcat(tmp, "/");
strcat(tmp, fn);
if(AUDIOPLAYER_GetFileInfo(tmp, &WavInfo) == 0)
{
strncpy((char *)pWavList->file[pWavList->ptr].name, (char *)tmp, FILEMGR_FILE_NAME_SIZE);
hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST);
LISTVIEW_AddRow(hItem, NULL);
FILEMGR_GetFileOnly (tmp, fn);
LISTVIEW_SetItemText(hItem, 0, pWavList->ptr, fn);
duration = WavInfo.FileSize / WavInfo.ByteRate;
sprintf((char *)tmp , "%02lu:%02lu", duration/60, duration%60 );
LISTVIEW_SetItemText(hItem, 1, pWavList->ptr, tmp);
pWavList->ptr++;
}if (AUDIOPLAYER_GetFileInfo(tmp, &WavInfo) == 0) { ... }
}if (((strstr(fn, ".wav")) || (strstr(fn, ".WAV"))) && (AUDIOPLAYER_hWin != 0)) { ... }
}if ((fno.fattrib & AM_DIR) == 0) { ... }
}if (pWavList->ptr < FILEMGR_LIST_DEPDTH) { ... }
}while (1) { ... }
}if (res == FR_OK) { ... }
f_closedir(&dir);
}{ ... }
/* ... */
static void _PlayFile(char *filename)
{
int duration;
static char tmp[FILEMGR_FILE_NAME_SIZE];
WM_HWIN hItem;
if(AUDIOPLAYER_GetFileInfo(filename, &WavInfo) == 0)
{
FILEMGR_GetFileOnly (tmp, filename);
TEXT_SetText(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_TITLE), tmp);
duration = WavInfo.FileSize / WavInfo.ByteRate;
sprintf((char *)tmp , "%02d:%02d", duration/60, duration%60 );
hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_TOTAL_TIME);
TEXT_SetText(hItem, tmp);
hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_AUTHOR);
TEXT_SetText(hItem, "Unknown");
hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_SAMPLING_VALUE);
sprintf((char *)tmp , "%lu Hz", WavInfo.SampleRate);
TEXT_SetText(hItem, tmp);
if(AUDIOPLAYER_SelectFile(filename) == 0)
{
AUDIOPLAYER_Play(WavInfo.SampleRate);
if(PlayerSettings.b.mute == MUTE_ON)
{
AUDIOPLAYER_Mute(MUTE_ON);
}if (PlayerSettings.b.mute == MUTE_ON) { ... }
}if (AUDIOPLAYER_SelectFile(filename) == 0) { ... }
}if (AUDIOPLAYER_GetFileInfo(filename, &WavInfo) == 0) { ... }
else
{
TEXT_SetText(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_TITLE), "Unknown");
hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_TOTAL_TIME);
TEXT_SetText(hItem, "--:--");
hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_SAMPLING_VALUE);
TEXT_SetText(hItem, "Unsupported Format");
}else { ... }
}{ ... }
/* ... */
AUDIOPLAYER_ErrorTypdef AUDIOPLAYER_NotifyEndOfFile(void)
{
WM_HWIN hItem;
AUDIOPLAYER_Stop();
if(PlayerSettings.b.repeat != REPEAT_NONE)
{
if (PlayerSettings.b.repeat == REPEAT_ALL)
{
if(file_pos < (pWavList->ptr - 1))
{
file_pos++;
}if (file_pos < (pWavList->ptr - 1)) { ... }
else
{
file_pos = 0;
}else { ... }
LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos);
}if (PlayerSettings.b.repeat == REPEAT_ALL) { ... }
_PlayFile((char *)pWavList->file[file_pos].name);
}if (PlayerSettings.b.repeat != REPEAT_NONE) { ... }
else
{
PlayerSettings.b.pause = PLAY_ACTIVE;
hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_PLAY_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
}else { ... }
return AUDIOPLAYER_ERROR_NONE;
}{ ... }
/* ... */
static void _cbDrawProgressSlider(WM_MESSAGE * pMsg) {
GUI_RECT Rect;
switch (pMsg->MsgId)
{
case WM_CREATE:
break;
case WM_CREATE:
case WM_PAINT:
WM_GetInsideRect(&Rect);
GUI_DrawGradientH(Rect.x0, Rect.y0, Rect.x1, Rect.y1, GUI_WHITE, 0x3F0000);
break;
case WM_PAINT:
default:
WM_DefaultProc(pMsg);default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbDrawVolumeSlider(WM_MESSAGE * pMsg) {
GUI_RECT Rect;
switch (pMsg->MsgId)
{
case WM_CREATE:
break;
case WM_CREATE:
case WM_PAINT:
WM_GetInsideRect(&Rect);
GUI_DrawGradientH(Rect.x0, Rect.y0, Rect.x1, Rect.y1, GUI_WHITE, 0x3F0000);
break;
case WM_PAINT:
default:
WM_DefaultProc(pMsg);default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbMediaConnection(WM_MESSAGE * pMsg)
{
WM_HWIN hItem;
static WM_HTIMER hStatusTimer;
static uint8_t prev_sd_status = 0;
static uint8_t prev_usb_status = 0;
switch (pMsg->MsgId)
{
case WM_CREATE:
prev_sd_status = k_StorageGetStatus(MSD_DISK_UNIT);
prev_usb_status = k_StorageGetStatus(USB_DISK_UNIT);
hStatusTimer = WM_CreateTimer(pMsg->hWin, 0, 500, 0);
break;
case WM_CREATE:
case WM_TIMER:
if(prev_sd_status != k_StorageGetStatus(MSD_DISK_UNIT))
{
prev_sd_status = k_StorageGetStatus(MSD_DISK_UNIT);
if(pWavList->file[file_pos].name[0] == '1')
{
if(PlayerSettings.b.pause == PAUSE_ACTIVE)
{
PlayerSettings.b.pause = PLAY_ACTIVE;
}if (PlayerSettings.b.pause == PAUSE_ACTIVE) { ... }
AUDIOPLAYER_Stop();
hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_ELAPSED_TIME);
TEXT_SetText(hItem, "00:00");
hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_PLAY_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
}if (pWavList->file[file_pos].name[0] == '1') { ... }
}if (prev_sd_status != k_StorageGetStatus(MSD_DISK_UNIT)) { ... }
else if(prev_usb_status != k_StorageGetStatus(USB_DISK_UNIT))
{
prev_usb_status = k_StorageGetStatus(USB_DISK_UNIT);
if(pWavList->file[file_pos].name[0] == '0')
{
if(PlayerSettings.b.pause == PAUSE_ACTIVE)
{
PlayerSettings.b.pause = PLAY_ACTIVE;
}if (PlayerSettings.b.pause == PAUSE_ACTIVE) { ... }
AUDIOPLAYER_Stop();
hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_ELAPSED_TIME);
TEXT_SetText(hItem, "00:00");
hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_PLAY_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
}if (pWavList->file[file_pos].name[0] == '0') { ... }
}else if (prev_usb_status != k_StorageGetStatus(USB_DISK_UNIT)) { ... }
WM_RestartTimer(pMsg->Data.v, 500);
break;
case WM_TIMER:
case WM_DELETE:
if(hStatusTimer != 0)
{
WM_DeleteTimer(hStatusTimer);
hStatusTimer = 0;
}if (hStatusTimer != 0) { ... }
break;
case WM_DELETE:
default:
WM_DefaultProc(pMsg);default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbDialog(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
int NCode;
int result;
int Id, ItemNbr;
int duration, volume, index;
static char tmp[FILEMGR_FILE_NAME_SIZE];
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
pWavList = (FILELIST_FileTypeDef *)k_malloc(sizeof(FILELIST_FileTypeDef));
pFileInfo = (CHOOSEFILE_INFO *)k_malloc(sizeof(CHOOSEFILE_INFO));
pWavList->ptr = 0;
hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST);
LISTVIEW_AddColumn(hItem, 250, "Track", GUI_TA_VCENTER | GUI_TA_LEFT);
LISTVIEW_AddColumn(hItem, 93, "Duration ", GUI_TA_VCENTER | GUI_TA_RIGHT);
LISTVIEW_SetGridVis(hItem, 0);
LISTVIEW_SetAutoScrollV(hItem, 1);
LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_UNSEL, GUI_BLACK);
LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_UNSEL, GUI_CYAN);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TITLE_CAPTION);
TEXT_SetText(hItem, "TITLE:");
TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
TEXT_SetTextColor(hItem, GUI_CYAN);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TITLE);
TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
TEXT_SetTextColor(hItem, GUI_CYAN);
hItem = WM_GetDialogItem(pMsg->hWin, ID_ELAPSED_TIME);
TEXT_SetText(hItem, "00:00");
TEXT_SetFont(hItem, GUI_FONT_D64);
TEXT_SetTextColor(hItem, GUI_GRAY);
hItem = WM_GetDialogItem(pMsg->hWin, ID_AUTHOR_CAPTION);
TEXT_SetText(hItem, "AUTHOR:");
TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
TEXT_SetTextColor(hItem, GUI_CYAN);
hItem = WM_GetDialogItem(pMsg->hWin, ID_AUTHOR);
TEXT_SetText(hItem, "");
TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
TEXT_SetTextColor(hItem, GUI_CYAN);
hItem = WM_GetDialogItem(pMsg->hWin, ID_SAMPLING_CAPTION);
TEXT_SetText(hItem, "SAMPLING:");
TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
TEXT_SetTextColor(hItem, GUI_CYAN);
hItem = WM_GetDialogItem(pMsg->hWin, ID_SAMPLING_VALUE);
TEXT_SetText(hItem, "");
TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
TEXT_SetTextColor(hItem, GUI_CYAN);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TOTAL_TIME);
TEXT_SetText(hItem, "00:00");
TEXT_SetFont(hItem, GUI_FONT_16_ASCII);
TEXT_SetTextColor(hItem, GUI_CYAN);
hItem = WM_GetDialogItem(pMsg->hWin, ID_ADD_BUTTON);
BUTTON_SetFont(hItem, GUI_FONT_24_1);
volume = AUDIOPLAYER_GetVolume();
hItem = WM_GetDialogItem(pMsg->hWin, ID_VOLUME_SLIDER);
SLIDER_SetValue(hItem, volume);
hItem = WM_GetDialogItem(pMsg->hWin, ID_DURATION_SLIDER);
SLIDER_SetNumTicks(hItem, 25);
PlayerSettings.d32 = k_BkupRestoreParameter(CALIBRATION_AUDIOPLAYER_SETTING_BKP);
PlayerSettings.b.mute = MUTE_OFF;
PlayerSettings.b.pause = PLAY_ACTIVE;
hItem = BUTTON_CreateEx(25, 150, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_REPEAT_BUTTON);
WM_SetCallback(hItem, _cbButton_repeat);
hItem = BUTTON_CreateEx(100, 145, 40, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_MUTE_BUTTON);
WM_SetCallback(hItem, _cbButton_speaker);
hItem = BUTTON_CreateEx(22, 337, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_STOP_BUTTON);
WM_SetCallback(hItem, _cbButton_stop);
hItem = BUTTON_CreateEx(89, 337, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_PREVIOUS_BUTTON);
WM_SetCallback(hItem, _cbButton_previous);
hItem = BUTTON_CreateEx(148, 330, 50, 50, pMsg->hWin, WM_CF_SHOW, 0, ID_PLAY_BUTTON);
WM_SetCallback(hItem, _cbButton_play);
hItem = BUTTON_CreateEx(222, 337, 35, 35, pMsg->hWin, WM_CF_SHOW, 0, ID_NEXT_BUTTON);
WM_SetCallback(hItem, _cbButton_next);
hItem = WM_GetClientWindow(pMsg->hWin);
hItem = BUTTON_CreateEx(20, 395, 50, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_WAV_BUTTON);
WM_SetCallback(hItem, _cbButton_open);
hItem = BUTTON_CreateEx(80, 395, 50, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_ADD_BUTTON);
WM_SetCallback(hItem, _cbButton_add);
hItem = BUTTON_CreateEx(235, 395, 30, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_CLOSE_BUTTON);
WM_SetCallback(hItem, _cbButton_close);
hTimerWin = WM_CreateWindowAsChild(0,
100,
10,
10,
pMsg->hWin,
WM_CF_SHOW | WM_CF_HASTRANS,
_cbAudioProcess,
0);
hItem = WM_CreateWindowAsChild(15,
125,
255,
20,
pMsg->hWin,
WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND,
_cbDrawProgressSlider,
0);
hItem = WM_CreateWindowAsChild(145,
155,
125,
20,
pMsg->hWin,
WM_CF_SHOW | WM_CF_HASTRANS | WM_CF_BGND,
_cbDrawVolumeSlider,
0);
WM_CreateWindowAsChild(639, 460, 1, 1, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMediaConnection , 0);
break;
case WM_INIT_DIALOG:
case WM_PAINT:
GUI_SetBkColor(GUI_BLACK);
GUI_ClearRect(15, 6, 270, 120);
GUI_DrawGradientRoundedV(15, 190, 270, 310, 30, 0x00A77009, 0x00FFFF00);
DrawRect3D(15, 325, 255, 60);
DrawRect3D(15, 390, 255, 40);
break;
case WM_PAINT:
case WM_DELETE:
AUDIOPLAYER_DeInit();
k_free(pWavList);
k_free(pFileInfo);
pWavList->ptr = 0;
PlayerSettings.b.mute = MUTE_OFF;
PlayerSettings.b.pause = PLAY_ACTIVE;
k_BkupSaveParameter(CALIBRATION_AUDIOPLAYER_SETTING_BKP, PlayerSettings.d32);
break;
case WM_DELETE:
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_CLOSE_BUTTON:
switch (NCode) {
case WM_NOTIFICATION_CLICKED:
break;case WM_NOTIFICATION_CLICKED:
case WM_NOTIFICATION_RELEASED:
GUI_EndDialog(pMsg->hWin, 0);
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_CLOSE_BUTTON:
case ID_REPEAT_BUTTON:
if(NCode == WM_NOTIFICATION_RELEASED)
{
hItem = WM_GetDialogItem(pMsg->hWin, ID_REPEAT_BUTTON);
if(PlayerSettings.b.repeat == REPEAT_NONE)
{
PlayerSettings.b.repeat = REPEAT_ONCE;
}if (PlayerSettings.b.repeat == REPEAT_NONE) { ... }
else if(PlayerSettings.b.repeat == REPEAT_ONCE)
{
PlayerSettings.b.repeat = REPEAT_ALL;
}else if (PlayerSettings.b.repeat == REPEAT_ONCE) { ... }
else if(PlayerSettings.b.repeat == REPEAT_ALL)
{
PlayerSettings.b.repeat = REPEAT_NONE;
}else if (PlayerSettings.b.repeat == REPEAT_ALL) { ... }
}if (NCode == WM_NOTIFICATION_RELEASED) { ... }
break;
case ID_REPEAT_BUTTON:
case ID_MUTE_BUTTON:
if(NCode == WM_NOTIFICATION_RELEASED)
{
hItem = WM_GetDialogItem(pMsg->hWin, ID_MUTE_BUTTON);
if(PlayerSettings.b.mute == MUTE_OFF)
{
AUDIOPLAYER_Mute(MUTE_ON);
PlayerSettings.b.mute = MUTE_ON;
}if (PlayerSettings.b.mute == MUTE_OFF) { ... }
else
{
AUDIOPLAYER_Mute(MUTE_OFF);
PlayerSettings.b.mute = MUTE_OFF;
}else { ... }
}if (NCode == WM_NOTIFICATION_RELEASED) { ... }
break;
case ID_MUTE_BUTTON:
case ID_VOLUME_SLIDER:
if(NCode == WM_NOTIFICATION_VALUE_CHANGED)
{
hItem = WM_GetDialogItem(pMsg->hWin, ID_VOLUME_SLIDER);
AUDIOPLAYER_SetVolume(SLIDER_GetValue(hItem));
if(PlayerSettings.b.mute == MUTE_ON)
{
AUDIOPLAYER_Mute(MUTE_OFF);
PlayerSettings.b.mute = MUTE_OFF;
}if (PlayerSettings.b.mute == MUTE_ON) { ... }
}if (NCode == WM_NOTIFICATION_VALUE_CHANGED) { ... }
break;
case ID_VOLUME_SLIDER:
case ID_DURATION_SLIDER:
if(NCode == WM_NOTIFICATION_CLICKED)
{
hItem = WM_GetDialogItem(pMsg->hWin, ID_DURATION_SLIDER);
AUDIOPLAYER_SetPosition(SLIDER_GetValue(hItem));
if(PlayerSettings.b.mute == MUTE_ON)
{
AUDIOPLAYER_Mute(MUTE_ON);
}if (PlayerSettings.b.mute == MUTE_ON) { ... }
}if (NCode == WM_NOTIFICATION_CLICKED) { ... }
break;
case ID_DURATION_SLIDER:
case ID_WAVFILE_LIST:
if(NCode == WM_NOTIFICATION_CLICKED)
{
hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST);
index = LISTVIEW_GetSel(hItem);
if(index < pWavList->ptr)
{
if(playlist_select == 0)
{
hPlaylistTimer = WM_CreateTimer(hTimerWin, ID_PLAYLIST_TIMER, 500, 0);
playlist_select = (index + 1);
}if (playlist_select == 0) { ... }
else if(playlist_select == (index + 1))
{
WM_DeleteTimer(hPlaylistTimer);
hPlaylistTimer = 0;
playlist_select = 0;
if(index < pWavList->ptr)
{
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
AUDIOPLAYER_Stop();
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
PlayerSettings.b.pause = PLAY_ACTIVE;
hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
file_pos = index;
_PlayFile((char *)pWavList->file[index].name);
}if (index < pWavList->ptr) { ... }
}else if (playlist_select == (index + 1)) { ... }
}if (index < pWavList->ptr) { ... }
}if (NCode == WM_NOTIFICATION_CLICKED) { ... }
break;
case ID_WAVFILE_LIST:
case ID_PLAY_BUTTON:
if(NCode == WM_NOTIFICATION_RELEASED)
{
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_STOP)
{
if(pWavList->ptr > 0)
{
_PlayFile((char *)pWavList->file[file_pos].name);
LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos);
}if (pWavList->ptr > 0) { ... }
else
{
pFileInfo->pfGetData = k_GetData;
pFileInfo->pMask = acMask_audio;
hItem = CHOOSEFILE_Create(pMsg->hWin, 70, 40, 450, 250, apDrives, GUI_COUNTOF(apDrives), 0, "Open an audio file", 0, pFileInfo);
WM_MakeModal(hItem);
result = GUI_ExecCreatedDialog(hItem);
if (result == 0)
{
if((strstr(pFileInfo->pRoot, ".wav")) || (strstr(pFileInfo->pRoot, ".WAV")))
{
if(AUDIOPLAYER_GetFileInfo(pFileInfo->pRoot, &WavInfo) == 0)
{
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
AUDIOPLAYER_Stop();
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
pWavList->ptr = 0;
file_pos = 0;
strcpy((char *)pWavList->file[pWavList->ptr].name, pFileInfo->pRoot);
FILEMGR_GetFileOnly (tmp, pFileInfo->pRoot);
hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST);
strcpy((char *)pWavList->file[pWavList->ptr].name, pFileInfo->pRoot);
ItemNbr = LISTVIEW_GetNumRows(hItem);
while(ItemNbr--)
{
LISTVIEW_DeleteRow(hItem, ItemNbr);
}while (ItemNbr--) { ... }
LISTVIEW_AddRow(hItem, NULL);
LISTVIEW_SetItemText(hItem, 0, pWavList->ptr, tmp);
duration = WavInfo.FileSize / WavInfo.ByteRate;
sprintf((char *)tmp , "%02d:%02d", duration/60, duration%60 );
LISTVIEW_SetItemText(hItem, 1, pWavList->ptr, tmp);
pWavList->ptr++;
LISTVIEW_SetSel(hItem, 0);
_PlayFile(pFileInfo->pRoot);
}if (AUDIOPLAYER_GetFileInfo(pFileInfo->pRoot, &WavInfo) == 0) { ... }
}if ((strstr(pFileInfo->pRoot, ".wav")) || (strstr(pFileInfo->pRoot, ".WAV"))) { ... }
}if (result == 0) { ... }
}else { ... }
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_STOP) { ... }
else if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
PlayerSettings.b.pause = (PlayerSettings.b.pause == PLAY_ACTIVE ? PAUSE_ACTIVE : PLAY_ACTIVE);
if(PlayerSettings.b.pause == PAUSE_ACTIVE)
{
AUDIOPLAYER_Pause();
}if (PlayerSettings.b.pause == PAUSE_ACTIVE) { ... }
else if(PlayerSettings.b.pause == PLAY_ACTIVE)
{
AUDIOPLAYER_Resume();
}else if (PlayerSettings.b.pause == PLAY_ACTIVE) { ... }
}else if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
}if (NCode == WM_NOTIFICATION_RELEASED) { ... }
break;
case ID_PLAY_BUTTON:
case ID_STOP_BUTTON:
if(NCode == WM_NOTIFICATION_RELEASED)
{
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
if(PlayerSettings.b.pause == PAUSE_ACTIVE)
{
PlayerSettings.b.pause = PLAY_ACTIVE;
}if (PlayerSettings.b.pause == PAUSE_ACTIVE) { ... }
AUDIOPLAYER_Stop();
hItem = WM_GetDialogItem(pMsg->hWin, ID_ELAPSED_TIME);
TEXT_SetText(hItem, "00:00");
hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
}if (NCode == WM_NOTIFICATION_RELEASED) { ... }
break;
case ID_STOP_BUTTON:
case ID_NEXT_BUTTON:
if(NCode == WM_NOTIFICATION_RELEASED)
{
if( pWavList->ptr > 0)
{
if(file_pos < (pWavList->ptr - 1))
{
file_pos++;
}if (file_pos < (pWavList->ptr - 1)) { ... }
else if(PlayerSettings.b.repeat == REPEAT_ALL)
{
file_pos = 0;
}else if (PlayerSettings.b.repeat == REPEAT_ALL) { ... }
LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos);
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
if(PlayerSettings.b.pause == PAUSE_ACTIVE)
{
PlayerSettings.b.pause = PLAY_ACTIVE;
hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
}if (PlayerSettings.b.pause == PAUSE_ACTIVE) { ... }
AUDIOPLAYER_Stop();
_PlayFile((char *)pWavList->file[file_pos].name);
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
}if (pWavList->ptr > 0) { ... }
}if (NCode == WM_NOTIFICATION_RELEASED) { ... }
break;
case ID_NEXT_BUTTON:
case ID_PREVIOUS_BUTTON:
if(NCode == WM_NOTIFICATION_RELEASED)
{
if( pWavList->ptr > 0)
{
if(file_pos > 0)
{
file_pos--;
}if (file_pos > 0) { ... }
else if(PlayerSettings.b.repeat == REPEAT_ALL)
{
file_pos = (pWavList->ptr - 1);
}else if (PlayerSettings.b.repeat == REPEAT_ALL) { ... }
LISTVIEW_SetSel(WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST), file_pos);
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
if(PlayerSettings.b.pause == PAUSE_ACTIVE)
{
PlayerSettings.b.pause = PLAY_ACTIVE;
hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
}if (PlayerSettings.b.pause == PAUSE_ACTIVE) { ... }
AUDIOPLAYER_Stop();
_PlayFile((char *)pWavList->file[file_pos].name);
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
}if (pWavList->ptr > 0) { ... }
}if (NCode == WM_NOTIFICATION_RELEASED) { ... }
break;
case ID_PREVIOUS_BUTTON:
case ID_WAV_BUTTON:
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
break;case WM_NOTIFICATION_CLICKED:
case WM_NOTIFICATION_RELEASED:
pFileInfo->pfGetData = k_GetData;
pFileInfo->pMask = acMask_dir;
hItem = CHOOSEFILE_Create(pMsg->hWin, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Add a folder", 0, pFileInfo);
WM_MakeModal(hItem);
result = GUI_ExecCreatedDialog(hItem);
if (result == 0)
{
_AddEntireFolder(pFileInfo->pRoot);
}if (result == 0) { ... }
break;
case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_WAV_BUTTON:
case ID_ADD_BUTTON:
switch(NCode) {
case WM_NOTIFICATION_RELEASED:
pFileInfo->pfGetData = k_GetData;
pFileInfo->pMask = acMask_audio;
hItem = CHOOSEFILE_Create(pMsg->hWin, 47, 10, 385, 215, apDrives, GUI_COUNTOF(apDrives), 0, "Add to playlist", 0, pFileInfo);
WM_MakeModal(hItem);
result = GUI_ExecCreatedDialog(hItem);
if (result == 0)
{
if((strstr(pFileInfo->pRoot, ".wav")) || (strstr(pFileInfo->pRoot, ".WAV")))
{
if(pWavList->ptr < FILEMGR_LIST_DEPDTH)
{
strcpy((char *)pWavList->file[pWavList->ptr].name, pFileInfo->pRoot);
FILEMGR_GetFileOnly (tmp, pFileInfo->pRoot);
hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST);
if(AUDIOPLAYER_GetFileInfo(pFileInfo->pRoot, &WavInfo) == 0)
{
LISTVIEW_AddRow(hItem, NULL);
LISTVIEW_SetItemText(hItem, 0, pWavList->ptr, tmp);
duration = WavInfo.FileSize / WavInfo.ByteRate;
sprintf((char *)tmp , "%02d:%02d", duration/60, duration%60 );
LISTVIEW_SetItemText(hItem, 1, pWavList->ptr, tmp);
pWavList->ptr++;
}if (AUDIOPLAYER_GetFileInfo(pFileInfo->pRoot, &WavInfo) == 0) { ... }
}if (pWavList->ptr < FILEMGR_LIST_DEPDTH) { ... }
}if ((strstr(pFileInfo->pRoot, ".wav")) || (strstr(pFileInfo->pRoot, ".WAV"))) { ... }
}if (result == 0) { ... }
break;
case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_ADD_BUTTON:
}switch (Id) { ... }
break;
case WM_NOTIFY_PARENT:
default:
WM_DefaultProc(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void Startup(WM_HWIN hWin, uint16_t xpos, uint16_t ypos)
{
AUDIOPLAYER_Init();
AUDIOPLAYER_hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, hWin, xpos, ypos);
}{ ... }
/* ... */
static void AudioDirectOpen(char *filename)
{
WM_HWIN hItem;
static char tmp[FILEMGR_FILE_NAME_SIZE];
pWavList->ptr = 0;
uint32_t duration;
AUDIOPLAYER_Init();
AUDIOPLAYER_hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_GetDesktopWindowEx(1), 0, 41);
if(AUDIOPLAYER_hWin != 0)
{
if(AUDIOPLAYER_GetFileInfo(filename, &WavInfo) == 0)
{
pWavList->ptr = 0;
file_pos = 0;
FILEMGR_GetFileOnly (tmp, filename);
hItem = WM_GetDialogItem(AUDIOPLAYER_hWin, ID_WAVFILE_LIST);
strcpy((char *)pWavList->file[pWavList->ptr].name, filename);
LISTVIEW_AddRow(hItem, NULL);
LISTVIEW_SetItemText(hItem, 0, pWavList->ptr, tmp);
duration = WavInfo.FileSize / WavInfo.ByteRate;
sprintf((char *)tmp , "%02lu:%02lu", duration/60, duration%60 );
LISTVIEW_SetItemText(hItem, 1, pWavList->ptr, tmp);
pWavList->ptr++;
LISTVIEW_SetSel(hItem, 0);
_PlayFile(filename);
}if (AUDIOPLAYER_GetFileInfo(filename, &WavInfo) == 0) { ... }
}if (AUDIOPLAYER_hWin != 0) { ... }
}{ ... }
/* ... */
/* ... */