1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
/** (c) Nullsoft, Inc. C O N F I D E N T I A L
** Filename:
** Project:
** Description:
** Author:
** Created:
**/
#include "Main.h"
#include "resource.h"
extern "C" extern int g_stopaftercur;
// button 1 (prev) functions
int Main_OnButton1(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
if (id == WINAMP_BUTTON1_SHIFT) SendMessageW(hwnd, WM_COMMAND, WINAMP_REW5S, 0);
else if (id == WINAMP_BUTTON1_CTRL)
{
PlayList_setposition(0);
if (config_shuffle) PlayList_randpos( -BIGINT);
PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
if (playing) StartPlaying();
else StopPlaying(0);
}
else
{
int nitem = SendMessageW(hMainWindow, WM_WA_IPC, 0, IPC_GET_PREVIOUS_PLITEM);
if (nitem != -1)
{
PlayList_setposition(nitem);
PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
StartPlaying();
}
else
{
int s = 1;
if (!config_shuffle && PlayList_advance( -1) < 0)
{
s = 0;
if (config_repeat)
{
s = 1;
PlayList_advance(BIGINT);
}
}
if (s)
{
if (PlayList_getlength())
{
if (config_shuffle)
{
if (PlayList_randpos( -1)) return 1;
}
PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
if (playing)
{
StopPlaying(0);
StartPlaying();
}
else StopPlaying(0);
}
}
}
}
return 1;
} // Main_OnButton1
// button 2 (play) functions
int Main_OnButton2(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
PlayList_resetcurrent();
if (!playing)
{
if (!no_notify_play)
{
FileName[0] = 0;
PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
}
if (id == WINAMP_BUTTON2_CTRL)
SendMessageW(hwnd, WM_COMMAND, WINAMP_FILE_LOC, 0);
else if (!FileName[0] || id == WINAMP_BUTTON2_SHIFT)
{
SendMessageW(hwnd, WM_COMMAND, WINAMP_FILE_PLAY, 0);
}
else
{
StartPlaying();
}
}
else
{
if (id == WINAMP_BUTTON2_CTRL)
SendMessageW(hwnd, WM_COMMAND, WINAMP_FILE_LOC, 0);
else if (id == WINAMP_BUTTON2_SHIFT)
SendMessageW(hwnd, WM_COMMAND, WINAMP_FILE_PLAY, 0);
else if (paused) UnPausePlaying();
else
{
PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
StartPlaying();
}
}
return 1;
} // Main_OnButton2
// button 3 (pause) functions
int Main_OnButton3(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
if (playing)
{
if (paused) UnPausePlaying();
else PausePlaying();
}
return 1;
}
// button 4 (stop) functions
int Main_OnButton4(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
if (playing)
{
if (id == WINAMP_BUTTON4_CTRL)
{
HMENU m;
int r;
g_stopaftercur = !g_stopaftercur;
r = g_stopaftercur ? MF_CHECKED : MF_UNCHECKED;
CheckMenuItem(main_menu, WINAMP_BUTTON4_CTRL, r);
m = GetSubMenu(top_menu, 3);
CheckMenuItem(m, WINAMP_BUTTON4_CTRL, r);
return 1;
}
if (id == WINAMP_BUTTON4_SHIFT && !paused)
{
// double v=0;
int x = 256;
int v = config_volume;
// double v = (double)(int)config_volume;
//double dv;// = -v / 256.;//(double)x;
int delay = 8;//2000 / x;
// v = (double)config_volume;
//dv = -v / 256.;
while (x--)
{
if (v < 0) v = 0;
in_setvol((int)v);
// v += dv;
v--;
Sleep(delay);
}
Sleep(100);
PausePlaying();
in_flush(in_getouttime());
in_setvol(config_volume);
}
StopPlaying(0);
}
return 1;
}
// button 5 (next) fucntions
int Main_OnButton5(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
if (id == WINAMP_BUTTON5_SHIFT)
SendMessageW(hwnd, WM_COMMAND, WINAMP_FFWD5S, 0);
else if (id == WINAMP_BUTTON5_CTRL)
{
PlayList_setposition(BIGINT);
if (config_shuffle)
{
PlayList_randpos( -BIGINT);
PlayList_randpos(PlayList_getlength() - 1);
}
PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
if (playing) StartPlaying();
else StopPlaying(0);
}
else
{
int nitem = SendMessageW(hMainWindow, WM_WA_IPC, 0, IPC_GET_NEXT_PLITEM);
if (nitem != -1)
{
PlayList_setposition(nitem);
PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
StartPlaying();
}
else if (!config_shuffle && PlayList_advance(1) < 0)
{
if (config_repeat)
{
PlayList_setposition(0);
PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
if (playing)
{
StopPlaying(0);
StartPlaying();
}
else StopPlaying(0);
}
}
else
{
if (!PlayList_getlength()) return 1;
if (config_shuffle)
{
int lp = PlayList_getPosition();
int q = PlayList_randpos(1);
if (q || PlayList_getlength() == 1)
{
if (!config_repeat) return 1;
PlayList_randpos( -BIGINT);
}
if (PlayList_getPosition() == lp && PlayList_getlength() > 1)
{
PlayList_randpos(1);
}
}
else
{
// 5.64 - if pledit is cleared, shuffle is off & we're playing
// then we set playing to go back to the start of the playlist
// as we get complaints it'll go to #2 instead of #1 as shown.
if (plcleared)
{
plcleared = 0;
PlayList_setposition(0);
}
}
PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
if (playing)
{
StopPlaying(0);
StartPlaying();
}
else StopPlaying(0);
}
}
return 1;
} // Main_OnButton5()
|