13 Commits
6 changed files with 98 additions and 16 deletions

No files matched your search

BIN
View File
Binary file not shown.
+1 -1
View File
@@ -22,7 +22,7 @@
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{c734fda7-262e-4202-8f4e-5e3031cb9935}</ProjectGuid>
<RootNamespace>EasyAudioPlayer</RootNamespace>
<RootNamespace>ClickPlay</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>ClickPlay</ProjectName>
</PropertyGroup>
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

+87 -12
View File
@@ -43,7 +43,8 @@ wstring ext[EXT_LENGTH] = { L"mp3", L"wav" };
//PATH VARS
vector<WIN32_FIND_DATA> files;
wstring path;
double selected = -1;
wstring currentSearchPhrase;
__int64 selected = -1;
//STATE VARS
/*
@@ -54,7 +55,7 @@ double selected = -1;
*/
int currentState = -1;
BOOL isOnClickPlayEnabled = TRUE;
BOOL isAutoPlayEnabled = FALSE;
BOOL isAutoPlayEnabled = TRUE;
BOOL isLoopEnabled = FALSE;
BOOL isQueued = FALSE;
BOOL showExtensions = FALSE;
@@ -73,6 +74,7 @@ HMENU menuBar;
//HOOKS
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK JumpToProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
bool alphabeticSort(WIN32_FIND_DATA a, WIN32_FIND_DATA b);
@@ -109,7 +111,7 @@ int WINAPI WinMain(HINSTANCE currentInst, HINSTANCE previousInst, LPSTR lpCmdLin
//INITIALIZE MESSAGE LOOP
while (GetMessage(&msg, NULL, 0, 0)) {
if (!TranslateAccelerator(msg.hwnd, shortcuts, &msg)) {
if (!TranslateAccelerator(mainWindow, shortcuts, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
@@ -301,11 +303,13 @@ int SearchDir(wstring phrase) {
if (path.empty()) {
return -2;
}
if (phrase == currentSearchPhrase) {
return 0;
}
//RELOAD DIR
if (LoadDir(path) != 0) {
return -2;
}
//PREPARE
if (phrase.empty()) {
return -3;
}
@@ -318,10 +322,12 @@ int SearchDir(wstring phrase) {
}
if (results.empty()) {
MessageBox(mainWindow, L"Nie znaleziono plików zawieraj¹cych wpisan¹ frazê.", L"Brak plików", MB_ICONEXCLAMATION);
currentSearchPhrase.clear();
return -1;
}
std::sort(results.begin(), results.end(), alphabeticSort);
files = results;
currentSearchPhrase = phrase;
//ADD FILTERED CONTENT
GenerateList(files);
return 0;
@@ -329,7 +335,7 @@ int SearchDir(wstring phrase) {
//GET SEARCH PHRASE FROM searchBox
wstring GetSearchPhrase() {
double searchLength = SendMessage(searchBox, WM_GETTEXTLENGTH, 0, NULL);
__int64 searchLength = SendMessage(searchBox, WM_GETTEXTLENGTH, 0, NULL);
TCHAR* searchPhrase = new TCHAR[searchLength + 1];
SendMessage(searchBox, WM_GETTEXT, searchLength + 1, (LPARAM)searchPhrase);
searchPhrase[(int)searchLength] = _T('\0');
@@ -367,14 +373,16 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
break;
case IDC_LIST:
if (windowEvent == LBN_SELCHANGE) {
if (currentState == 1 || currentState == 2) { currentState = 1; isQueued = TRUE; }
if (LoadSelection(GetIndex()) == 0) {
if (isOnClickPlayEnabled == TRUE) {
SendMessage(mainWindow, STATE_CHANGE, 1, NULL);
if (selected != SendMessage(filesListCtrl, LB_GETCURSEL, 0, 0)) {
if (currentState == 1 || currentState == 2) { currentState = 1; isQueued = TRUE; }
if (LoadSelection(GetIndex()) == 0) {
if (isOnClickPlayEnabled == TRUE) {
SendMessage(mainWindow, STATE_CHANGE, 1, NULL);
}
}
else {
SendMessage(mainWindow, STATE_CHANGE, 0, 0);
}
}
else {
SendMessage(mainWindow, STATE_CHANGE, 0, 0);
}
}
break;
@@ -408,6 +416,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
isQueued = FALSE;
UnloadSelection();
SendMessage(mainWindow, STATE_CHANGE, 0, NULL);
SendMessage(filesListCtrl, LB_SETCURSEL, -1, 0);
break;
case IDM_EXIT:
SendMessage(mainWindow, WM_CLOSE, NULL, NULL);
@@ -446,6 +455,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
}
UnloadSelection();
SendMessage(mainWindow, STATE_CHANGE, 0, 0);
SendMessage(filesListCtrl, LB_SETCURSEL, -1, 0);
break;
case ID_OPCJE_SHOWEXT:
if (showExtensions) {
@@ -467,6 +477,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
SendMessage(mainWindow, STATE_CHANGE, -1, NULL);
break;
case ID_AKCJE_SRCLEAR:
currentSearchPhrase.clear();
SendMessage(searchBox, WM_SETTEXT, (WPARAM)L"", 0);
SendMessage(mainWindow, STATE_CHANGE, 0, 0);
if (LoadDir(path) != 0) {
@@ -481,6 +492,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
srand(time(NULL));
//LOAD AND PLAY
randIndex = rand() % files.size();
if (randIndex == selected && randIndex + 1 < files.size()) { randIndex += 1; }
if (LoadSelection(randIndex) == 0) {
SendMessage(filesListCtrl, LB_SETCURSEL, randIndex, 0);
SendMessage(mainWindow, STATE_CHANGE, 1, 0);
@@ -500,6 +512,10 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
}
UnloadSelection();
SendMessage(mainWindow, STATE_CHANGE, 0, 0);
SendMessage(filesListCtrl, LB_SETCURSEL, -1, 0);
break;
case ID_AKCJE_JUMP:
DialogBox(globalInstance, MAKEINTRESOURCE(IDD_JUMPTODIALOG), mainWindow, JumpToProc);
break;
}
break;
@@ -528,6 +544,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
if (selected != -1) {
UnloadSelection();
SendMessage(mainWindow, STATE_CHANGE, 0, NULL);
SendMessage(filesListCtrl, LB_SETCURSEL, -1, 0);
}
}
}
@@ -535,6 +552,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
if (selected != -1) {
UnloadSelection();
SendMessage(mainWindow, STATE_CHANGE, 0, NULL);
SendMessage(filesListCtrl, LB_SETCURSEL, -1, 0);
}
}
}
@@ -556,6 +574,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
EnableMenuItem(menuBar, ID_PLIK_CLOSEDIR, MF_DISABLED);
EnableMenuItem(menuBar, ID_AKCJE_RANDOM, MF_DISABLED);
EnableMenuItem(menuBar, ID_AKCJE_SRCLEAR, MF_DISABLED);
EnableMenuItem(menuBar, ID_AKCJE_JUMP, MF_DISABLED);
SetWindowText(dirLabel, NO_DIR_LOADED_LABEL);
SetWindowText(npLabel, NOT_PLAYING_LABEL);
SetWindowText(playButton, PLAY_LABEL);
@@ -570,6 +589,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
EnableMenuItem(menuBar, ID_PLIK_CLOSEDIR, MF_ENABLED);
EnableMenuItem(menuBar, ID_AKCJE_RANDOM, MF_ENABLED);
EnableMenuItem(menuBar, ID_AKCJE_SRCLEAR, MF_ENABLED);
EnableMenuItem(menuBar, ID_AKCJE_JUMP, MF_DISABLED);
SetWindowText(npLabel, NOT_PLAYING_LABEL);
SetWindowText(playButton, PLAY_LABEL);
break;
@@ -607,6 +627,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
EnableMenuItem(menuBar, ID_PLIK_CLOSEDIR, MF_ENABLED);
EnableMenuItem(menuBar, ID_AKCJE_RANDOM, MF_ENABLED);
EnableMenuItem(menuBar, ID_AKCJE_SRCLEAR, MF_ENABLED);
EnableMenuItem(menuBar, ID_AKCJE_JUMP, MF_ENABLED);
SetWindowText(npLabel, files[selected].cFileName);
SetWindowText(playButton, PAUSE_LABEL);
break;
@@ -629,6 +650,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
EnableMenuItem(menuBar, ID_PLIK_CLOSEDIR, MF_ENABLED);
EnableMenuItem(menuBar, ID_AKCJE_RANDOM, MF_ENABLED);
EnableMenuItem(menuBar, ID_AKCJE_SRCLEAR, MF_ENABLED);
EnableMenuItem(menuBar, ID_AKCJE_JUMP, MF_ENABLED);
SetWindowText(npLabel, pauseString);
SetWindowText(playButton, L"Wznów");
break;
@@ -641,6 +663,59 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
return NULL;
}
//JUMP TO DIALOG LOOP
INT_PTR CALLBACK JumpToProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
UNREFERENCED_PARAMETER(lParam);
switch (msg) {
case WM_INITDIALOG:
SetDlgItemText(hwnd, IDC_TSMIN, L"00");
SetDlgItemText(hwnd, IDC_TSSEC, L"00");
return (INT_PTR)TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK) {
TCHAR* minB = new TCHAR[32];
TCHAR* secB = new TCHAR[32];
GetDlgItemText(hwnd, IDC_TSMIN, minB, 30);
GetDlgItemText(hwnd, IDC_TSSEC, secB, 30);
int min = 0;
int sec = 0;
try {
min = std::stoi(minB);
sec = std::stoi(secB);
if (!(min >= 0 && min <= 999 && sec >= 0 && sec <= 59)) {
MessageBox(mainWindow, L"Podane wartoœci s¹ niepoprawne", L"Niepoprawne wartoœci", MB_ICONEXCLAMATION);
EndDialog(hwnd, LOWORD(wParam));
return (INT_PTR)TRUE;
}
}
catch (...) {
MessageBox(mainWindow, L"Podane wartoœci s¹ niepoprawne", L"Niepoprawne wartoœci", MB_ICONEXCLAMATION);
EndDialog(hwnd, LOWORD(wParam));
return (INT_PTR)TRUE;
}
int timestamp = (((min * 60) + sec) * 1000);
isQueued = TRUE;
wstring mciCmd = L"play mp3 from " + std::to_wstring(timestamp);
mciSendString(mciCmd.c_str(), NULL, 0, mainWindow);
SendMessage(mainWindow, STATE_CHANGE, 1, 0);
EndDialog(hwnd, LOWORD(wParam));
return (INT_PTR)TRUE;
}
else if (LOWORD(wParam) == IDCANCEL) {
EndDialog(hwnd, LOWORD(wParam));
return (INT_PTR)TRUE;
}
}
return (INT_PTR)FALSE;
}
//ABOUT DIALOG LOOP
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
UNREFERENCED_PARAMETER(lParam);
+10 -3
View File
@@ -11,7 +11,13 @@
#define IDI_SMALL 108
#define IDC_CLICKPLAY 109
#define IDR_MAINFRAME 128
#define IDD_JUMPTODIALOG 130
#define IDC_MENU 200
#define IDC_SEARCHBTN 205
#define IDC_PLAYBTN 207
#define IDC_STOPBTN 208
#define IDC_TSSEC 1000
#define IDC_TSMIN 1001
#define ID_REFRESH 32775
#define ID_OPCJE_ONCLICK 32776
#define ID_OPCJE_LOOP 32777
@@ -21,6 +27,7 @@
#define ID_AKCJE_RANDOM 32781
#define ID_OPCJE_SHOWEXT 32782
#define ID_OPCJE_AUTOPLAY 32783
#define ID_AKCJE_JUMP 32784
#define IDC_STATIC -1
// Next default values for new objects
@@ -28,9 +35,9 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 130
#define _APS_NEXT_COMMAND_VALUE 32784
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_RESOURCE_VALUE 131
#define _APS_NEXT_COMMAND_VALUE 32785
#define _APS_NEXT_CONTROL_VALUE 1002
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif