1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
30
31
39
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
111
112
113
118
119
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
156
157
168
169
174
175
176
177
178
185
192
193
194
195
196
197
202
203
204
205
206
213
220
221
222
223
224
225
230
231
232
233
234
235
242
249
250
251
252
253
254
259
270
271
276
280
281
286
290
291
296
300
305
316
321
332
333
338
349
354
365
366
371
382
383
388
399
400
405
416
417
418
423
424
425
426
427
428
429
436
443
444
445
446
447
448
453
454
455
456
457
458
459
466
473
474
475
476
477
478
483
484
485
486
487
488
495
502
503
504
505
506
507
512
523
524
529
540
541
546
557
562
594
595
600
601
602
603
604
605
606
607
608
609
610
611
616
617
618
619
620
621
622
626
627
628
629
630
631
632
633
634
635
636
637
638
645
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
692
694
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
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
811
812
817
818
819
820
821
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
919
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
1000
1027
1028
1029
1030
1033
1034
1035
1036
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1063
1077
1080
1081
1082
1083
1084
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1136
1137
1138
1139
1140
1141
1142
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1189
1190
1191
1197
1198
1199
1200
1201
1202
1203
1207
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1247
1248
1249
1250
1251
1252
1257
1258
1259
1260
1261
1262
1263
1264
1269
1270
1271
1272
1273
1274
1275
1276
1280
1284
1285
1286
1287
1288
1289
1290
1291
1292
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
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
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1384
1385
1386
1387
1392
1393
1398
1399
1400
1401
1402
1403
1408
1423
1424
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1481
1482
1483
1484
1485
1486
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1555
1556
1557
1558
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1584
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1627
1628
1629
1630
1631
1632
1635
1636
/* ... */
#include "main.h"
#include "video_player_res.c"
/* ... */
/* ... */
Includes
static void Startup(WM_HWIN hWin, uint16_t xpos, uint16_t ypos);
static void FILEMGR_GetFileOnly (char *file, char *path);
static void _StopPlay(WM_HWIN *hmovie, FIL * file) ;
static uint8_t _StartPlay(WM_HWIN *hmovie, char * filename, FIL * file, uint16_t x0, uint16_t y0) ;
static void _cbMediaConnection(WM_MESSAGE * pMsg);
static void _AddEntireFolder(char *Foldername);
Private function prototypes
K_ModuleItem_Typedef video_player_board =
{
2,
"video player",
open_video,
0,
Startup,
NULL,
...}
;
Private typedef
#define VIDEO_FRAME_ID (GUI_ID_USER + 0x00)
#define VIDEO_TITLE_ID (GUI_ID_USER + 0x01)
#define SELECT_FILE1_ID (GUI_ID_USER + 0x02)
#define PLAY_VIDEO1_ID (GUI_ID_USER + 0x03)
#define FPS1_CAPTION_ID (GUI_ID_USER + 0x06)
#define FPS1_VALUE_ID (GUI_ID_USER + 0x07)
#define LostFrames11_CAPTION_ID (GUI_ID_USER + 0x0B)
#define LostFrames11_VALUE_ID (GUI_ID_USER + 0x0C)
#define FILENAME1_ID (GUI_ID_USER + 0x19)
#define ID_BUTTON_EXIT (GUI_ID_USER + 0x1B)
#define ID_BUTTON_EXIT_FROM_VIDEO (GUI_ID_USER + 0x1C)
#define PLAY_VIDEO_ID (GUI_ID_USER + 0x1D)
#define ID_BUTTON_STOP (GUI_ID_USER + 0x1E)
#define ID_VIDEO_LIST (GUI_ID_USER + 0x1F)
#define ID_BUTTON_MENU (GUI_ID_USER + 0x20)
#define ID_ICONVIEW_SUBMENU (GUI_ID_USER + 0x30)
#define ID_BUTTON_OKPL (GUI_ID_USER + 0x31)
#define ID_BUTTON_ADDPL (GUI_ID_USER + 0x32)
#define ID_BUTTON_NEXT (GUI_ID_USER + 0x33)
#define ID_BUTTON_PREVIOUS (GUI_ID_USER + 0x34)
#define ID_BUTTON_BACK (GUI_ID_USER + 0x35)
#define ID_BUTTON_FORE (GUI_ID_USER + 0x36)
#define ID_FRAMEWIN_0 (GUI_ID_USER + 0x37)
#define ID_BUTTON_OK_MESSAGE (GUI_ID_USER + 0x38)
#define ID_TEXT_FILENAME (GUI_ID_USER + 0x39)
#define ID_TIME (GUI_ID_USER + 0x40)
#define ID_ELAPSED_TIME (GUI_ID_USER + 0x41)
#define ID_VIDEO_NAME (GUI_ID_USER + 0x42)
#define ID_FPS (GUI_ID_USER + 0x43)
#define ID_FEATURES_FPU (GUI_ID_USER + 0x44)
#define ID_FEATURES_IC (GUI_ID_USER + 0x45)
#define ID_FEATURES_DC (GUI_ID_USER + 0x46)
#define ID_FEATURES_CPU (GUI_ID_USER + 0x47)
#define ID_SLIDER_DURATION (GUI_ID_USER + 0x48)
#define ID_VIDEO_FORMAT (GUI_ID_USER + 0x49)
#define ID_TIMER_CONNECTION (GUI_ID_USER + 0x50)
#define ID_TIMER_PROCESS (GUI_ID_USER + 0x51)
#define VIDEO_IDLE 0
#define VIDEO_PLAY 1
#define VIDEO_STOP 2
#define VIDEO_PAUSE 3
#define VIDEO_FRAME_TIME 40
42 defines
Private defines
static const GUI_WIDGET_CREATE_INFO _aDialog[] = {
{ WINDOW_CreateIndirect, "Window", VIDEO_FRAME_ID, 0, 0, 800, 480, 0, 0x0, 0 },
...};
static const GUI_WIDGET_CREATE_INFO _aFileInfoDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "Video player", ID_FRAMEWIN_0, 0, 0, 600, 350, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Please Add Video file to playList", ID_TEXT_FILENAME, 90, 140, 430, 30, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "OK", ID_BUTTON_OK_MESSAGE, 230, 240, 120, 120, 0, 0x0, 0 },
...};
static const GUI_WIDGET_CREATE_INFO _aPlaylistDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "Playlist", ID_FRAMEWIN_0, 0, 0, 600, 350, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "OK", ID_BUTTON_OKPL, 520, 240, 120, 120, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Add", ID_BUTTON_ADDPL, (-60), 240, 120, 120, 0, 0x0, 0 },
...};
static GUI_MOVIE_HANDLE hvideo;
static GUI_MOVIE_HANDLE playbackwin;
static WM_HWIN VideoWin = 0, hFrame = 0, hPlaylistWin = 0;
uint8_t VideoPlayer_State = VIDEO_IDLE;
static char const *apDrives[1] = {"0:"};
static const char acMask_video[] = ".video";
FIL Video_File;
uint8_t Video_Path[256];
uint8_t SelLayer = 0;
static FILELIST_FileTypeDef VideoList;
static CHOOSEFILE_INFO FileInfo;
static uint32_t Video_FilePos = 0;
static WM_HTIMER hTimer;
static uint32_t elapsed_time = 0;
GUI_MOVIE_INFO Video_Info;
uint32_t step = 0;
static __IO uint32_t FrameIndex = 0, PrevFrameIndex = 0;
static __IO uint32_t LostFrames = 0, previous_total = 0;
/* ... */
static int GUI_WaitForDialogExec (WM_HWIN hDialog) {
WM_DIALOG_STATUS DialogStatus = {0};
GUI_SetDialogStatusPtr(hDialog, &DialogStatus);
while (!DialogStatus.Done) {
if (!GUI_Exec()) {
GUI_Delay(100);
}if (!GUI_Exec()) { ... }
}while (!DialogStatus.Done) { ... }
return DialogStatus.ReturnValue;
}{ ... }
/* ... */
static void _OnPaint_exit(BUTTON_Handle hObj) {
GUI_SetBkColor(GUI_WHITE);
GUI_Clear();
if((WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED))
{
GUI_SetColor(GUI_DARKGRAY);
GUI_AA_FillCircle(100, 0, 100);
GUI_SetBkColor(GUI_DARKGRAY);
GUI_SetColor(GUI_WHITE);
}if ((WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED)) { ... }
else
{
GUI_SetColor(GUI_STCOLOR_LIGHTBLUE);
GUI_AA_FillCircle(100, 0, 100);
GUI_SetBkColor(GUI_STCOLOR_LIGHTBLUE);
GUI_SetColor(GUI_WHITE);
}else { ... }
GUI_SetFont(&GUI_FontLubalGraph32);
GUI_DispStringAt("Menu", 20, 20);
}{ ... }
/* ... */
static void _OnPaint_exit1(BUTTON_Handle hObj) {
GUI_SetBkColor(GUI_TRANSPARENT);
GUI_Clear();
if((WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED))
{
GUI_SetColor(GUI_DARKGRAY);
GUI_AA_FillCircle(0, 100, 100);
GUI_SetBkColor(GUI_DARKGRAY);
GUI_SetColor(GUI_WHITE);
}if ((WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED)) { ... }
else
{
GUI_SetColor(GUI_STCOLOR_LIGHTBLUE);
GUI_AA_FillCircle(0, 100, 100);
GUI_SetBkColor(GUI_STCOLOR_LIGHTBLUE);
GUI_SetColor(GUI_WHITE);
}else { ... }
GUI_SetFont(&GUI_FontLubalGraph32);
GUI_DispStringAt("back", 10, 35);
}{ ... }
/* ... */
static void _OnPaint_menu(BUTTON_Handle hObj) {
GUI_SetBkColor(GUI_TRANSPARENT);
GUI_Clear();
if((WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED))
{
GUI_SetColor(GUI_DARKGRAY);
GUI_AA_FillCircle(100, 0, 100);
GUI_SetBkColor(GUI_DARKGRAY);
GUI_SetColor(GUI_WHITE);
}if ((WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED)) { ... }
else
{
GUI_SetColor(GUI_STCOLOR_LIGHTBLUE);
GUI_AA_FillCircle(100, 0, 100);
GUI_SetBkColor(GUI_STCOLOR_LIGHTBLUE);
GUI_SetColor(GUI_WHITE);
}else { ... }
GUI_SetFont(&GUI_FontLubalGraph32);
GUI_DispStringAt("Menu", 20, 20);
}{ ... }
/* ... */
static void _OnPaint_play(BUTTON_Handle hObj) {
if(VideoPlayer_State != VIDEO_PLAY)
{
GUI_DrawBitmap(&bmplay, 0, 0);
}if (VideoPlayer_State != VIDEO_PLAY) { ... }
else
{
GUI_DrawBitmap(&bmpause, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_stop(BUTTON_Handle hObj) {
GUI_DrawBitmap(&bmstop, 0, 0);
}{ ... }
/* ... */
static void _OnPaint_back(BUTTON_Handle hObj) {
GUI_DrawBitmap(&bmback, 0, 0);
}{ ... }
/* ... */
static void _OnPaint_fore(BUTTON_Handle hObj) {
GUI_DrawBitmap(&bmfore, 0, 0);
}{ ... }
/* ... */
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_back(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_back(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_fore(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_fore(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_exit1(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_exit1(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_menu(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_menu(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_exit(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_exit(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _OnPaint_add2PL(BUTTON_Handle hObj) {
GUI_SetBkColor(GUI_WHITE);
GUI_Clear();
if((WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED))
{
GUI_SetColor(GUI_DARKGRAY);
GUI_AA_FillCircle(56, 60, 60);
GUI_SetBkColor(GUI_DARKGRAY);
GUI_SetColor(GUI_WHITE);
}if ((WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED)) { ... }
else
{
GUI_SetColor(GUI_STCOLOR_LIGHTBLUE);
GUI_AA_FillCircle(56, 60, 60);
GUI_SetBkColor(GUI_STCOLOR_LIGHTBLUE);
GUI_SetColor(GUI_WHITE);
}else { ... }
GUI_SetFont(&GUI_Font24B_1);
GUI_DispStringAt("Add", 65, 30);
}{ ... }
/* ... */
static void _OnPaint_okPL(BUTTON_Handle hObj) {
GUI_SetBkColor(GUI_WHITE);
GUI_Clear();
if((WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED))
{
GUI_SetColor(GUI_DARKGRAY);
GUI_AA_FillCircle(68, 60, 60);
GUI_SetBkColor(GUI_DARKGRAY);
GUI_SetColor(GUI_WHITE);
}if ((WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED)) { ... }
else
{
GUI_SetColor(GUI_STCOLOR_LIGHTBLUE);
GUI_AA_FillCircle(68, 60, 60);
GUI_SetBkColor(GUI_STCOLOR_LIGHTBLUE);
GUI_SetColor(GUI_WHITE);
}else { ... }
GUI_SetFont(&GUI_FontLubalGraph24B);
GUI_DispStringAt("OK", 24, 30);
}{ ... }
/* ... */
static void _OnPaint_okMessage(BUTTON_Handle hObj) {
GUI_SetBkColor(GUI_WHITE);
GUI_Clear();
if((WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED))
{
GUI_SetColor(GUI_DARKGRAY);
GUI_AA_FillCircle(60, 60, 50);
GUI_SetBkColor(GUI_DARKGRAY);
GUI_SetColor(GUI_WHITE);
}if ((WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED)) { ... }
else
{
GUI_SetColor(GUI_STCOLOR_LIGHTBLUE);
GUI_AA_FillCircle(60, 60, 50);
GUI_SetBkColor(GUI_STCOLOR_LIGHTBLUE);
GUI_SetColor(GUI_WHITE);
}else { ... }
GUI_SetFont(&GUI_FontLubalGraph24B);
GUI_DispStringAt("OK", 43, 35);
}{ ... }
/* ... */
static void _cbButton_add2PL(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_add2PL(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_okPL(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_okPL(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_okMessage(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_okMessage(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbTouch(WM_MESSAGE * pMsg)
{
const GUI_PID_STATE * pState;
static uint8_t toggle = 0;
switch (pMsg->MsgId)
{
case WM_TOUCH:
pState = (const GUI_PID_STATE *)pMsg->Data.p;
if (pState)
{
if (pState->Pressed == 1)
{
if(!toggle)
{
GUI_SetLayerVisEx (1, 0);
}if (!toggle) { ... }
else
{
GUI_SetLayerVisEx (1, 1);
}else { ... }
toggle ^= 1;
WM_Exec();
}if (pState->Pressed == 1) { ... }
}if (pState) { ... }
break;
case WM_TOUCH:
default:
WM_DefaultProc(pMsg);
break; default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbMediaConnection(WM_MESSAGE * pMsg)
{
static WM_HTIMER hStatusTimer;
static uint8_t prev_usb_status = 0;
WM_HWIN hItem = 0;
static char tmp[64];
uint32_t i = 0;
switch (pMsg->MsgId)
{
case WM_CREATE:
prev_usb_status = k_StorageGetStatus(USB_DISK_UNIT);
hStatusTimer = WM_CreateTimer(pMsg->hWin, ID_TIMER_CONNECTION, 500, 0);
break;
case WM_CREATE:
case WM_TIMER:
if(prev_usb_status != k_StorageGetStatus(USB_DISK_UNIT))
{
prev_usb_status = k_StorageGetStatus(USB_DISK_UNIT);
if(prev_usb_status == 0)
{
if(VideoPlayer_State != VIDEO_IDLE)
{
_StopPlay(&hvideo, &Video_File);
}if (VideoPlayer_State != VIDEO_IDLE) { ... }
VideoList.ptr = 0;
if(playbackwin)
{
GUI_EndDialog(playbackwin, 0);
playbackwin = 0;
SelLayer = 0;
GUI_SetLayerVisEx (1, 0);
GUI_SelectLayer(0);
WM_InvalidateWindow(VideoWin);
}if (playbackwin) { ... }
if(hFrame)
{
WM_HideWindow(hFrame);
WM_Exec();
WM_DeleteWindow(hFrame);
hFrame = 0;
}if (hFrame) { ... }
if(hPlaylistWin)
{
hItem = WM_GetDialogItem(hPlaylistWin, ID_VIDEO_LIST);
i = LISTVIEW_GetNumRows(hItem);
while(i--)
{
LISTVIEW_DeleteRow(hItem, i);
}while (i--) { ... }
}if (hPlaylistWin) { ... }
}if (prev_usb_status == 0) { ... }
else
{
VideoList.ptr = 0;
_AddEntireFolder("0:");
_AddEntireFolder("0:/Video");
if(hPlaylistWin)
{
if(VideoList.ptr > 0)
{
for(i=0; i<VideoList.ptr; i++)
{
strcpy(FileInfo.pRoot, (char *)VideoList.file[i].name);
FILEMGR_GetFileOnly ((char *)tmp, (char *)FileInfo.pRoot);
hItem = WM_GetDialogItem(hPlaylistWin, ID_VIDEO_LIST);
LISTVIEW_AddRow(hItem, NULL);
LISTVIEW_SetItemText(hItem, 0, i, (char *)tmp);
}for (i=0; i
WM_InvalidateWindow(hItem);
WM_Update(hItem);
}if (VideoList.ptr > 0) { ... }
}if (hPlaylistWin) { ... }
}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 int _GetData(void * p, const U8 ** ppData, unsigned NumBytesReq, U32 Off)
{
unsigned int NumBytesRead;
f_lseek((FIL *)p, Off);
f_read((FIL *)p, (U8 *)*ppData, NumBytesReq, &NumBytesRead);
return NumBytesRead;
}{ ... }
/* ... */
static void _cbplaybackwin(WM_MESSAGE * pMsg)
{
WM_HWIN hItem;
int Id, NCode;
char tmp[64];
switch (pMsg->MsgId)
{
case WM_CREATE:
SelLayer = 1;
hItem = BUTTON_CreateEx(255, 430, 80, 80, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_BACK);
WM_SetCallback(hItem, _cbButton_back);
hItem = BUTTON_CreateEx(320, 430, 80, 80, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_STOP);
WM_SetCallback(hItem, _cbButton_stop);
hItem = BUTTON_CreateEx(385, 430, 80, 80, pMsg->hWin, WM_CF_SHOW, 0, PLAY_VIDEO_ID);
WM_SetCallback(hItem, _cbButton_play);
hItem = BUTTON_CreateEx(450, 430, 80, 80, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_FORE);
WM_SetCallback(hItem, _cbButton_fore);
hItem = SLIDER_CreateEx(140, 400, 530, 20, pMsg->hWin, WM_CF_SHOW, 0, ID_SLIDER_DURATION);
SLIDER_SetBkColor(hItem, GUI_TRANSPARENT);
SLIDER_SetFocusColor (hItem, GUI_STCOLOR_LIGHTBLUE);
SLIDER_SetValue(hItem, 0);
SLIDER_SetWidth(hItem, 0);
SLIDER_SetSTSkin(hItem);
hItem = BUTTON_CreateEx(700, 0, 100, 100, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_MENU);
WM_SetCallback(hItem, _cbButton_menu);
hItem = BUTTON_CreateEx(0, 379, 100, 100, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_EXIT_FROM_VIDEO);
WM_SetCallback(hItem, _cbButton_exit1);
hItem = TEXT_CreateEx(10, 15, 120, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_ELAPSED_TIME, "00:00");
TEXT_SetFont(hItem, &GUI_FontAvantGarde24B);
TEXT_SetTextColor(hItem, GUI_WHITE);
hItem = TEXT_CreateEx(40, 40, 120, 40, pMsg->hWin, WM_CF_SHOW, 0, ID_TIME, "00:00");
TEXT_SetFont(hItem, &GUI_FontAvantGarde20B);
TEXT_SetTextColor(hItem, GUI_WHITE);
hItem = TEXT_CreateEx(205, 10, 350, 50, pMsg->hWin, WM_CF_SHOW, TEXT_CF_HCENTER, ID_VIDEO_NAME, "File Name");
TEXT_SetFont(hItem, &GUI_FontAvantGarde24B);
TEXT_SetTextColor(hItem, GUI_WHITE);
hItem = TEXT_CreateEx(200, 40, 350, 50, pMsg->hWin, WM_CF_SHOW, TEXT_CF_HCENTER, ID_VIDEO_FORMAT, "Format : MJPEG");
TEXT_SetFont(hItem, &GUI_FontAvantGarde20B);
TEXT_SetTextColor(hItem, GUI_WHITE);
hItem = TEXT_CreateEx(660, 220, 200, 40, pMsg->hWin, WM_CF_SHOW, TEXT_CF_LEFT, ID_FPS, "Rate : -- fps");
TEXT_SetFont(hItem, &GUI_FontAvantGarde20B);
TEXT_SetTextColor(hItem, GUI_WHITE);
hItem = TEXT_CreateEx(660, 245, 200, 40, pMsg->hWin, WM_CF_SHOW, TEXT_CF_LEFT, ID_FEATURES_FPU, "FPU : ON");
TEXT_SetFont(hItem, &GUI_FontAvantGarde20B);
TEXT_SetTextColor(hItem, GUI_WHITE);
hItem = TEXT_CreateEx(660, 270, 200, 40, pMsg->hWin, WM_CF_SHOW, TEXT_CF_LEFT, ID_FEATURES_CPU, "MCU Load : 0%");
TEXT_SetFont(hItem, &GUI_FontAvantGarde20B);
TEXT_SetTextColor(hItem, GUI_WHITE);
break;
case WM_CREATE:
case WM_TIMER:
{
WM_RestartTimer(pMsg->Data.v, 1000);
hItem = WM_GetDialogItem(pMsg->hWin, ID_ELAPSED_TIME);
elapsed_time++;
sprintf((char *)tmp , "%02lu:%02lu", elapsed_time/60, elapsed_time%60 );
TEXT_SetText(hItem, tmp);
sprintf((char *)tmp , "MCU Load : %d%%", osGetCPUUsage());
hItem = WM_GetDialogItem(pMsg->hWin, ID_FEATURES_CPU);
TEXT_SetText(hItem, tmp);
hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_DURATION);
SLIDER_SetValue(hItem, (GUI_MOVIE_GetFrameIndex(hvideo)* 100)/ Video_Info.NumFrames);
if(step == 0)
{
step = ((GUI_MOVIE_GetFrameIndex(hvideo)* 100)/ Video_Info.NumFrames);
}if (step == 0) { ... }
if(((GUI_MOVIE_GetFrameIndex(hvideo)* 100)/ Video_Info.NumFrames) > (100 - 2*step - 1))
{
SLIDER_SetValue(hItem, 100);
GUI_Exec();
}if (((GUI_MOVIE_GetFrameIndex(hvideo)* 100)/ Video_Info.NumFrames) > (100 - 2*step - 1)) { ... }
...}
break;
case WM_TIMER:
case WM_DELETE:
if(hTimer != 0)
{
WM_DeleteTimer(hTimer);
hTimer = 0;
}if (hTimer != 0) { ... }
playbackwin = 0;
break;
case WM_DELETE:
case WM_PAINT:
GUI_SetColor(0xFF000000 | GUI_BLACK);
GUI_SetBkColor(GUI_TRANSPARENT);
GUI_Clear();
GUI_SetColor(GUI_BLACK);
GUI_DrawHLine(0, 0, 800);
GUI_DrawHLine(479, 0, 800);
GUI_DrawLine(799, 0, 799, 480);
GUI_DrawLine(0, 0, 0, 480);
GUI_SetColor(GUI_STCOLOR_LIGHTBLUE);
GUI_AA_FillRoundedRect((-30), 5, 100, 70, 20);
GUI_AA_FillRoundedRect(200, 5, 570, 70, 20);
GUI_AA_FillRoundedRect(650, 200, 900, 305, 30);
break;
case WM_PAINT:
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_BUTTON_EXIT_FROM_VIDEO:
switch(NCode) {
case WM_NOTIFICATION_RELEASED:
if(VideoPlayer_State != VIDEO_IDLE)
{
_StopPlay(&hvideo, &Video_File);
}if (VideoPlayer_State != VIDEO_IDLE) { ... }
GUI_EndDialog(pMsg->hWin, 0);
SelLayer = 0;
GUI_SetLayerVisEx (1, 0);
GUI_SelectLayer(0);
WM_HideWindow(hFrame);
WM_Exec();
WM_DeleteWindow(hFrame);
WM_InvalidateWindow(VideoWin);
hFrame = 0;
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_BUTTON_EXIT_FROM_VIDEO:
case ID_BUTTON_MENU:
switch(NCode) {
case WM_NOTIFICATION_RELEASED:
if(VideoPlayer_State != VIDEO_IDLE)
{
_StopPlay(&hvideo, &Video_File);
}if (VideoPlayer_State != VIDEO_IDLE) { ... }
GUI_EndDialog(pMsg->hWin, 0);
SelLayer = 0;
GUI_SetLayerVisEx (1, 0);
GUI_SelectLayer(0);
WM_DeleteWindow(hFrame);
WM_HideWindow(VideoWin);
WM_Exec();
WM_DeleteWindow(VideoWin);
hFrame = 0;
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_BUTTON_MENU:
case ID_BUTTON_STOP:
switch(NCode) {
case WM_NOTIFICATION_RELEASED:
if(VideoPlayer_State != VIDEO_IDLE)
{
VideoPlayer_State = VIDEO_STOP;
_StopPlay(&hvideo, &Video_File);
}if (VideoPlayer_State != VIDEO_IDLE) { ... }
WM_InvalidateWindow(pMsg->hWin);
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_BUTTON_STOP:
case ID_BUTTON_FORE:
switch(NCode) {
case WM_NOTIFICATION_RELEASED:
if(Video_FilePos < (VideoList.ptr - 1))
{
Video_FilePos++;
}if (Video_FilePos < (VideoList.ptr - 1)) { ... }
else
{
Video_FilePos = 0;
}else { ... }
if((VideoPlayer_State == VIDEO_PLAY) ||
(VideoPlayer_State == VIDEO_PAUSE))
{
_StopPlay(&hvideo, &Video_File);
_StartPlay(&hvideo, (char *)VideoList.file[Video_FilePos].name, &Video_File, 0, 0);
VideoPlayer_State = VIDEO_PLAY;
}if ((VideoPlayer_State == VIDEO_PLAY) || (VideoPlayer_State == VIDEO_PAUSE)) { ... }
else
{
_StartPlay(&hvideo, (char *)VideoList.file[Video_FilePos].name, &Video_File, 0, 0);
_StopPlay(&hvideo, &Video_File);
}else { ... }
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_BUTTON_FORE:
case ID_SLIDER_DURATION:
if(NCode == WM_NOTIFICATION_CLICKED)
{
hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_DURATION);
int32_t newpos;
if(VideoPlayer_State == VIDEO_PLAY)
{
GUI_MOVIE_Pause(hvideo);
hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_DURATION);
newpos = (SLIDER_GetValue(hItem) * Video_Info.NumFrames)/100;
GUI_MOVIE_GotoFrame(hvideo, newpos);
GUI_MOVIE_Play(hvideo);
elapsed_time = (Video_Info.msPerFrame * newpos)/ 1000;
hItem = WM_GetDialogItem(playbackwin, ID_ELAPSED_TIME);
sprintf((char *)tmp , "%02lu:%02lu", elapsed_time/60, elapsed_time%60 );
TEXT_SetText(hItem, tmp);
WM_InvalidateWindow(hItem);
WM_Paint(hItem);
}if (VideoPlayer_State == VIDEO_PLAY) { ... }
}if (NCode == WM_NOTIFICATION_CLICKED) { ... }
break;
case ID_SLIDER_DURATION:
case ID_BUTTON_BACK:
switch(NCode) {
case WM_NOTIFICATION_RELEASED:
if(Video_FilePos > 0)
{
Video_FilePos--;
}if (Video_FilePos > 0) { ... }
else
{
Video_FilePos = VideoList.ptr - 1;
}else { ... }
if((VideoPlayer_State == VIDEO_PLAY) ||
(VideoPlayer_State == VIDEO_PAUSE))
{
_StopPlay(&hvideo, &Video_File);
_StartPlay(&hvideo, (char *)VideoList.file[Video_FilePos].name, &Video_File, 0, 0);
VideoPlayer_State = VIDEO_PLAY;
}if ((VideoPlayer_State == VIDEO_PLAY) || (VideoPlayer_State == VIDEO_PAUSE)) { ... }
else
{
_StartPlay(&hvideo, (char *)VideoList.file[Video_FilePos].name, &Video_File, 0, 0);
_StopPlay(&hvideo, &Video_File);
}else { ... }
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_BUTTON_BACK:
case PLAY_VIDEO_ID:
switch(NCode) {
case WM_NOTIFICATION_RELEASED:
if((VideoPlayer_State == VIDEO_IDLE) || (VideoPlayer_State == VIDEO_PAUSE))
{
hTimer = WM_CreateTimer(playbackwin, ID_TIMER_PROCESS, 1000, 0);
GUI_MOVIE_Play(hvideo);
VideoPlayer_State = VIDEO_PLAY;
}if ((VideoPlayer_State == VIDEO_IDLE) || (VideoPlayer_State == VIDEO_PAUSE)) { ... }
else if(VideoPlayer_State == VIDEO_STOP)
{
_StartPlay(&hvideo, (char *)VideoList.file[Video_FilePos].name, &Video_File, 0, 0);
VideoPlayer_State = VIDEO_PLAY;
}else if (VideoPlayer_State == VIDEO_STOP) { ... }
else
{
GUI_MOVIE_Pause(hvideo);
VideoPlayer_State = VIDEO_PAUSE;
if(hTimer != 0)
{
WM_DeleteTimer(hTimer);
hTimer = 0;
}if (hTimer != 0) { ... }
}else { ... }
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break; case PLAY_VIDEO_ID:
}switch (Id) { ... }
break;
case WM_NOTIFY_PARENT:
default:
WM_DefaultProc(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbFileInfoDialog(WM_MESSAGE * pMsg) {
int NCode;
int Id;
WM_HWIN hItem;
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OK_MESSAGE);
WM_SetCallback(hItem, _cbButton_okMessage);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_FILENAME);
TEXT_SetFont(hItem, &GUI_FontAvantGarde32);
hItem = WM_GetDialogItem(pMsg->hWin, (ID_TEXT_FILENAME+2));
TEXT_SetFont(hItem, &GUI_FontAvantGarde32);
break;
case WM_INIT_DIALOG:
case WM_PAINT:
GUI_DrawBitmap(&bmwarning, 260, 60);
break;
case WM_PAINT:
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_BUTTON_OK_MESSAGE:
switch(NCode) {
case WM_NOTIFICATION_RELEASED:
GUI_EndDialog(pMsg->hWin, 0);
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;case ID_BUTTON_OK_MESSAGE:
}switch (Id) { ... }
break;case WM_NOTIFY_PARENT:
default:
WM_DefaultProc(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbPlaylistDialog(WM_MESSAGE * pMsg) {
int NCode;
int Id;
int r;
WM_HWIN hItem;
static char tmp[64];
uint32_t i = 0;
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_OKPL);
WM_SetCallback(hItem, _cbButton_okPL);
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_ADDPL);
WM_SetCallback(hItem, _cbButton_add2PL);
hItem = LISTVIEW_CreateEx(85, 50, 440, 260, pMsg->hWin, WM_CF_SHOW, 0, ID_VIDEO_LIST);
LISTVIEW_SetFont(hItem, &GUI_FontAvantGarde24);
LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_UNSEL, GUI_STCOLOR_LIGHTBLUE);
LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_SEL, GUI_WHITE);
LISTVIEW_SetHeaderHeight(hItem, 0);
LISTVIEW_AddColumn(hItem, 440, "", GUI_TA_VCENTER | GUI_TA_LEFT);
LISTVIEW_SetGridVis(hItem, 0);
LISTVIEW_SetAutoScrollV(hItem, 1);
WIDGET_SetEffect(hItem, &WIDGET_Effect_None);
LISTVIEW_SetTextAlign(hItem, 0, GUI_TA_HCENTER);
if(VideoList.ptr > 0)
{
for(i=0; i<VideoList.ptr; i++)
{
strcpy(FileInfo.pRoot, (char *)VideoList.file[i].name);
FILEMGR_GetFileOnly ((char *)tmp, (char *)FileInfo.pRoot);
LISTVIEW_AddRow(hItem, NULL);
LISTVIEW_SetItemText(hItem, 0, i, (char *)tmp);
}for (i=0; i
sprintf(tmp, "PlayList [%d Item(s)]", VideoList.ptr);
FRAMEWIN_SetText(pMsg->hWin, tmp);
}if (VideoList.ptr > 0) { ... }
else
{
FRAMEWIN_SetText(pMsg->hWin, "PlayList [no Item]");
}else { ... }
break;
case WM_INIT_DIALOG:
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_BUTTON_OKPL:
switch(NCode) {
case WM_NOTIFICATION_RELEASED:
GUI_EndDialog(pMsg->hWin, 0);
Video_FilePos = 0;
hPlaylistWin = 0;
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_BUTTON_OKPL:
case ID_BUTTON_ADDPL:
switch(NCode) {
case WM_NOTIFICATION_RELEASED:
FileInfo.pfGetData = k_GetData;
FileInfo.pMask = acMask_video;
hItem = ST_CHOOSEFILE_Create(pMsg->hWin, 0, 0, 600, 350, apDrives, GUI_COUNTOF(apDrives), 0, "Video files", 0, &FileInfo);
WM_MakeModal(hItem);
r = GUI_WaitForDialogExec(hItem);
if (r == 0)
{
if((strstr(FileInfo.pRoot, ".emf")) || (strstr(FileInfo.pRoot, ".EMF")))
{
if(VideoList.ptr < FILEMGR_LIST_DEPDTH)
{
strcpy((char *)VideoList.file[VideoList.ptr].name, FileInfo.pRoot);
FILEMGR_GetFileOnly ((char *)tmp, (char *)FileInfo.pRoot);
hItem = WM_GetDialogItem(pMsg->hWin, ID_VIDEO_LIST);
LISTVIEW_AddRow(hItem, NULL);
LISTVIEW_SetItemText(hItem, 0, VideoList.ptr, (char *)tmp);
VideoList.ptr++;
}if (VideoList.ptr < FILEMGR_LIST_DEPDTH) { ... }
}if ((strstr(FileInfo.pRoot, ".emf")) || (strstr(FileInfo.pRoot, ".EMF"))) { ... }
sprintf(tmp, "PlayList [%d Item(s)]", VideoList.ptr);
FRAMEWIN_SetText(pMsg->hWin, tmp);
WM_InvalidateWindow(pMsg->hWin);
}if (r == 0) { ... }
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_BUTTON_ADDPL:
}switch (Id) { ... }
break;case WM_NOTIFY_PARENT:
default:
WM_DefaultProc(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void FILEMGR_GetFileOnly (char *file, char *path)
{
char *baseName1, *baseName2;
baseName1 = strrchr(path,'/');
baseName2 = strrchr(path,':');
if(baseName1++)
{
strcpy(file, baseName1);
}if (baseName1++) { ... }
else
{
if (baseName2++)
{
strcpy(file, baseName2);
}if (baseName2++) { ... }
else
{
strcpy(file, path);
}else { ... }
}else { ... }
}{ ... }
/* ... */
void _cbNotify(GUI_HMEM hMem, int Notification, U32 CurrentFrame)
{
char tmp[20];
WM_HWIN hItem;
switch (Notification)
{
case GUI_MOVIE_NOTIFICATION_PREDRAW:
GUI_SelectLayer(0);
GUI_MULTIBUF_Begin();
FrameIndex = GUI_MOVIE_GetFrameIndex(hvideo);
if(FrameIndex < PrevFrameIndex)
{
PrevFrameIndex = FrameIndex;
previous_total = 0;
}if (FrameIndex < PrevFrameIndex) { ... }
LostFrames += (FrameIndex - PrevFrameIndex);
if((FrameIndex - previous_total) >= VIDEO_FRAME_TIME)
{
hItem = WM_GetDialogItem(playbackwin, ID_FPS);
if((VIDEO_FRAME_TIME - LostFrames + 1) < VIDEO_FRAME_TIME)
{
sprintf(tmp, "Rate : %lu fps", VIDEO_FRAME_TIME - LostFrames + 1);
TEXT_SetText(hItem, tmp);
}if ((VIDEO_FRAME_TIME - LostFrames + 1) < VIDEO_FRAME_TIME) { ... }
LostFrames = 0;
previous_total = FrameIndex;
}if ((FrameIndex - previous_total) >= VIDEO_FRAME_TIME) { ... }
PrevFrameIndex = FrameIndex + 1;
break;
case GUI_MOVIE_NOTIFICATION_PREDRAW:
case GUI_MOVIE_NOTIFICATION_POSTDRAW:
GUI_MULTIBUF_End();
GUI_SelectLayer(1);
break;
case GUI_MOVIE_NOTIFICATION_POSTDRAW:
case GUI_MOVIE_NOTIFICATION_STOP:
{
if(GUI_MOVIE_GetFrameIndex(hvideo) >= (Video_Info.NumFrames - 1))
{
_StopPlay(&hvideo, &Video_File);
if(Video_FilePos < (VideoList.ptr - 1))
{
Video_FilePos++;
}if (Video_FilePos < (VideoList.ptr - 1)) { ... }
else
{
Video_FilePos = 0;
}else { ... }
_StartPlay(&hvideo, (char *)VideoList.file[Video_FilePos].name, &Video_File, 0, 0);
}if (GUI_MOVIE_GetFrameIndex(hvideo) >= (Video_Info.NumFrames - 1)) { ... }
...}
break;case GUI_MOVIE_NOTIFICATION_STOP:
}switch (Notification) { ... }
}{ ... }
/* ... */
static uint8_t _StartPlay(GUI_MOVIE_HANDLE *hmovie, char * filename, FIL * file, uint16_t x0, uint16_t y0)
{
static char tmp[FILEMGR_FILE_NAME_SIZE];
uint32_t ms, frames, duration;
WM_HWIN hItem;
if(f_open(file, filename, FA_OPEN_EXISTING | FA_READ) == FR_OK)
{
PrevFrameIndex = 0;
LostFrames = 0;
previous_total = 0;
GUI_MOVIE_GetInfoEx(_GetData, file, &Video_Info);
*hmovie = GUI_MOVIE_CreateEx(_GetData, file, _cbNotify) ;
GUI_MOVIE_SetPeriod (*hmovie, VIDEO_FRAME_TIME);
if((Video_Info.xSize == 0) || (Video_Info.ySize == 0) ||
(Video_Info.xSize > LCD_GetXSize()) || (Video_Info.ySize > LCD_GetYSize()))
{
_StopPlay(hmovie, file);
VideoPlayer_State = VIDEO_STOP;
hItem = WM_GetDialogItem(playbackwin, ID_VIDEO_NAME);
FILEMGR_GetFileOnly (tmp, filename);
TEXT_SetText(hItem, tmp);
hItem = WM_GetDialogItem(playbackwin, ID_ELAPSED_TIME);
TEXT_SetText(hItem, "00:00");
WM_InvalidateWindow(hItem);
WM_Paint(hItem);
hItem = WM_GetDialogItem(playbackwin, ID_TIME);
TEXT_SetText(hItem, "00:00");
WM_InvalidateWindow(hItem);
WM_Paint(hItem);
hItem = WM_GetDialogItem(playbackwin, ID_VIDEO_FORMAT);
sprintf(tmp, "Format : UNSUPPORTED [%lu/%d]", Video_FilePos + 1, VideoList.ptr) ;
TEXT_SetText(hItem, tmp);
WM_InvalidateWindow(hItem);
WM_Paint(hItem);
return 1;
}if ((Video_Info.xSize == 0) || (Video_Info.ySize == 0) || (Video_Info.xSize > LCD_GetXSize()) || (Video_Info.ySize > LCD_GetYSize())) { ... }
GUI_MOVIE_Show(*hmovie, ((LCD_GetXSize() - Video_Info.xSize)/2), ((LCD_GetYSize() - Video_Info.ySize)/2), 0);
hTimer = WM_CreateTimer(playbackwin, ID_TIMER_PROCESS, 1000, 0);
hItem = WM_GetDialogItem(playbackwin, ID_TIME);
ms = Video_Info.msPerFrame;
frames = Video_Info.NumFrames;
duration = (frames * ms)/1000;
sprintf((char *)tmp , "%02lu:%02lu", duration/60, duration%60 );
TEXT_SetText(hItem, tmp);
WM_InvalidateWindow(playbackwin);
elapsed_time = 0;
hItem = WM_GetDialogItem(playbackwin, ID_VIDEO_NAME);
FILEMGR_GetFileOnly (tmp, filename);
TEXT_SetText(hItem, tmp);
hItem = WM_GetDialogItem(playbackwin, ID_ELAPSED_TIME);
TEXT_SetText(hItem, "00:00");
WM_InvalidateWindow(hItem);
WM_Paint(hItem);
hItem = WM_GetDialogItem(playbackwin, ID_VIDEO_FORMAT);
sprintf(tmp, "Format : MJPEG [%lu/%d]", Video_FilePos + 1, VideoList.ptr) ;
TEXT_SetText(hItem, tmp);
WM_InvalidateWindow(hItem);
WM_Paint(hItem);
}if (f_open(file, filename, FA_OPEN_EXISTING | FA_READ) == FR_OK) { ... }
return 0;
}{ ... }
/* ... */
static void _StopPlay(GUI_MOVIE_HANDLE *hmovie, FIL * file)
{
if(hTimer != 0)
{
WM_DeleteTimer(hTimer);
hTimer = 0;
}if (hTimer != 0) { ... }
if(*hmovie != 0)
{
GUI_MOVIE_Delete (*hmovie);
*hmovie = 0;
}if (*hmovie != 0) { ... }
f_close(file);
WM_InvalidateWindow(hFrame);
}{ ... }
/* ... */
static void _cbVideoWindow(WM_MESSAGE * pMsg)
{
GUI_RECT r;
switch (pMsg->MsgId)
{
case WM_PAINT:
WM_GetInsideRect(&r);
GUI_ClearRectEx(&r);
break;
case WM_PAINT:
default:
WM_DefaultProc(pMsg);default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbDialog(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
int Id, NCode;
static uint8_t sel = 0;
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
memset(Video_Path, 0, 256);
hItem = BUTTON_CreateEx(700, 0, 100, 100, pMsg->hWin, WM_CF_SHOW, 0, ID_BUTTON_EXIT);
WM_SetCallback(hItem, _cbButton_exit);
hItem = ST_AnimatedIconView_CreateEx(120,
50,
LCD_GetXSize() - 220,
LCD_GetYSize() - 150,
pMsg->hWin,
WM_CF_SHOW | WM_CF_HASTRANS ,
0,
ID_ICONVIEW_SUBMENU,
240,
300, 20, 5);
ST_AnimatedIconView_SetDualFont(hItem, &GUI_FontLubalGraph24, &GUI_FontLubalGraph24);
ST_AnimatedIconView_SetSpace(hItem, GUI_COORD_Y, 5);
ST_AnimatedIconView_SetSpace(hItem, GUI_COORD_X, 25);
ST_AnimatedIconView_SetFrame(hItem, GUI_COORD_Y, 10);
ST_AnimatedIconView_SetFrame(hItem, GUI_COORD_X, 5);
ST_AnimatedIconView_SetSel(hItem, -1);
ST_AnimatedIconView_SetTextColor(hItem, ICONVIEW_CI_UNSEL, GUI_STCOLOR_LIGHTBLUE);
ST_AnimatedIconView_SetBkColor(hItem, ICONVIEW_CI_UNSEL, GUI_WHITE);
ST_AnimatedIconView_SetBkColor(hItem, ICONVIEW_CI_SEL, GUI_WHITE);
ST_AnimatedIconView_SetDualTextColor(hItem, ICONVIEW_CI_SEL, GUI_STCOLOR_LIGHTBLUE, GUI_STCOLOR_DARKBLUE);
ST_AnimatedIconView_AddIcon(hItem, open_file, 0, "Play video");
ST_AnimatedIconView_AddIcon(hItem, add_video, 0, "Open playlist");
break;
case WM_INIT_DIALOG:
case WM_PAINT:
GUI_SetColor(GUI_BLACK);
GUI_DrawLine(799, 0, 799, 480);
break;
case WM_PAINT:
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_BUTTON_EXIT:
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
hItem = WM_GetDialogItem(pMsg->hWin, ID_ICONVIEW_SUBMENU);
WM_HideWindow(hItem);
break;
case WM_NOTIFICATION_CLICKED:
case WM_NOTIFICATION_MOVED_OUT:
hItem = WM_GetDialogItem(pMsg->hWin, ID_ICONVIEW_SUBMENU);
WM_ShowWindow(hItem);
break;
case WM_NOTIFICATION_MOVED_OUT:
case WM_NOTIFICATION_RELEASED:
GUI_EndDialog(pMsg->hWin, 0);
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_BUTTON_EXIT:
case ID_ICONVIEW_SUBMENU:
switch(NCode) {
case WM_NOTIFICATION_RELEASED:
sel = ST_AnimatedIconView_GetSel(pMsg->hWinSrc);
if(sel == 0)
{
if(VideoList.ptr > 0)
{
GUI_SetLayerVisEx (1, 1);
GUI_SelectLayer(1);
playbackwin = WM_CreateWindowAsChild(0, 0, 800, 480, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbplaybackwin , 0);
WM_CreateWindowAsChild(100, 100, 600, 280, WM_GetDesktopWindowEx(1), WM_CF_SHOW | WM_CF_HASTRANS, _cbTouch , 0);
GUI_SelectLayer(0);
_StartPlay(&hvideo, (char *)VideoList.file[0].name, &Video_File, 0, 0);
VideoPlayer_State = VIDEO_PLAY;
hFrame = WM_CreateWindowAsChild(0, 0, 800, 480,pMsg->hWin, WM_CF_SHOW, _cbVideoWindow , 0);
GUI_SelectLayer(1);
}if (VideoList.ptr > 0) { ... }
else
{
hItem = GUI_CreateDialogBox(_aFileInfoDialogCreate,
GUI_COUNTOF(_aFileInfoDialogCreate),
_cbFileInfoDialog,
pMsg->hWin,
100, 50);
WM_MakeModal(hItem);
}else { ... }
}if (sel == 0) { ... }
else if(sel == 1)
{
hPlaylistWin = GUI_CreateDialogBox(_aPlaylistDialogCreate,
GUI_COUNTOF(_aPlaylistDialogCreate),
_cbPlaylistDialog,
pMsg->hWin,
100, 50);
WM_MakeModal(hPlaylistWin);
}else if (sel == 1) { ... }
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;case ID_ICONVIEW_SUBMENU:
}switch (Id) { ... }
break;case WM_NOTIFY_PARENT:
default:
WM_DefaultProc(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _AddEntireFolder(char *Foldername)
{
FRESULT res;
FILINFO fno;
DIR dir;
char *fn;
static char tmp[FILEMGR_FILE_NAME_SIZE];
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 (VideoList.ptr < FILEMGR_LIST_DEPDTH)
{
if ((fno.fattrib & AM_DIR) == 0)
{
if((strstr(fn, ".emf")) || (strstr(fn, ".EMF")))
{
strcpy(tmp, Foldername);
strcat(tmp, "/");
strcat(tmp, fn);
strncpy((char *)VideoList.file[VideoList.ptr].name, (char *)tmp, FILEMGR_FILE_NAME_SIZE);
VideoList.ptr++;
}if ((strstr(fn, ".emf")) || (strstr(fn, ".EMF"))) { ... }
}if ((fno.fattrib & AM_DIR) == 0) { ... }
}if (VideoList.ptr < FILEMGR_LIST_DEPDTH) { ... }
}while (1) { ... }
}if (res == FR_OK) { ... }
f_closedir(&dir);
}{ ... }
/* ... */
static void Startup(WM_HWIN hWin, uint16_t xpos, uint16_t ypos)
{
VideoPlayer_State = VIDEO_IDLE;
Video_FilePos = 0;
if(VideoList.ptr == 0)
{
_AddEntireFolder("0:");
}if (VideoList.ptr == 0) { ... }
_AddEntireFolder("0:/Video");
VideoWin = GUI_CreateDialogBox(_aDialog, GUI_COUNTOF(_aDialog), _cbDialog, hWin, xpos, ypos);
WM_CreateWindowAsChild(799, 479, 1, 1, VideoWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMediaConnection , 0);
}{ ... }
/* ... */
/* ... */