1 | /*
|
---|
2 | * This file is (C) Chris Wohlgemuth 2002
|
---|
3 | *
|
---|
4 | * It's part of the Media-Folder distribution
|
---|
5 | */
|
---|
6 | /*
|
---|
7 | * This program is free software; you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation; either version 2, or (at your option)
|
---|
10 | * any later version.
|
---|
11 | *
|
---|
12 | * This program is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with this program; see the file COPYING. If not, write to
|
---|
19 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #define INCL_DOSERRORS
|
---|
23 | #define INCL_REXXSAA
|
---|
24 |
|
---|
25 | #include "mediafolder.hh"
|
---|
26 | #include <stdio.h>
|
---|
27 | #include <stdlib.h>
|
---|
28 | #include <string.h>
|
---|
29 | #include "except.h"
|
---|
30 | #include <rexxsaa.h> /* needed for RexxStart() */
|
---|
31 | #include "mediafolderres.h"
|
---|
32 |
|
---|
33 | #include "sys_funcs.h"
|
---|
34 | /* typedef for somTP_MMAudio_cwmmQueryTrackInfo */
|
---|
35 | #include "cwmmquerytrackinfo.h"
|
---|
36 |
|
---|
37 | int iWaveDev=0;
|
---|
38 |
|
---|
39 | extern HMTX hmtxFileName;
|
---|
40 | extern char chrInstallDir[];
|
---|
41 |
|
---|
42 | HMODULE queryResModuleHandle(void);
|
---|
43 | BOOL getMessage(char* text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd);
|
---|
44 |
|
---|
45 | ULONG cwRequestMutex(HMTX hmtxBMP, ULONG ulTimeOut);
|
---|
46 | ULONG cwReleaseMutex(HMTX hmtxBMP);
|
---|
47 |
|
---|
48 | MRESULT EXPENTRY settingsToolbarOptionDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
---|
49 | extern void showPlayTimeDisplay(CWMediaFolder *thisPtr, BOOL bShow);
|
---|
50 | void setPlayTimeText2(CWMediaFolder *thisPtr, char * theText);
|
---|
51 | void setPlayTimeText(CWMediaFolder *thisPtr);
|
---|
52 | extern void _resetDisplay(CWMediaFolder *thisPtr);
|
---|
53 |
|
---|
54 | extern BOOL cwmmQueryCWAudioMethodPtr(CWMediaFolder *thisPtr);
|
---|
55 | extern SOMClass* queryMMAudioClass(void);
|
---|
56 | SOMClass* somhlpGetSomClass(char* chrClassName);
|
---|
57 | /* Get the HWND of the play control dialog. This Dialog is on top of
|
---|
58 | the top frame control. */
|
---|
59 | HWND playControlDialogFromFrameHWND(HWND hwndFrame);
|
---|
60 | /* Get the HWND of the frame control at the top */
|
---|
61 | HWND topControlFromFrameHWND(HWND hwndFrame);
|
---|
62 | /* Get the HWND of the time display static text control. */
|
---|
63 | HWND playTimeControlFromFrameHWND(HWND hwndFrame);
|
---|
64 |
|
---|
65 | /* This procedure is called for example from the play dialog. It's used to keep
|
---|
66 | the code tidier. */
|
---|
67 | void callMediaFolderMethod(CWMediaFolder *thisPtr, ULONG ulAction, ULONG ulData)
|
---|
68 | {
|
---|
69 | switch(ulAction)
|
---|
70 | {
|
---|
71 | case PLAY_FIRST:
|
---|
72 | /* Send a message to the object window created by the folder play thread */
|
---|
73 | WinPostMsg(thisPtr->mfData->hwndPlayObject,WM_APPTERMINATENOTIFY, 0,MPFROMLONG(PLAY_FIRST));
|
---|
74 | break;
|
---|
75 | case STOP_TRACK:
|
---|
76 | WinPostMsg(thisPtr->mfData->hwndPlayObject,WM_APPTERMINATENOTIFY, 0,MPFROMLONG(STOP_TRACK));
|
---|
77 | break;
|
---|
78 | case PLAY_NEXT:
|
---|
79 | WinPostMsg(thisPtr->mfData->hwndPlayObject,WM_APPTERMINATENOTIFY, 0,MPFROMLONG(PLAY_NEXT));
|
---|
80 | break;
|
---|
81 | case PLAY_PREV:
|
---|
82 | WinPostMsg(thisPtr->mfData->hwndPlayObject,WM_APPTERMINATENOTIFY, 0,MPFROMLONG(PLAY_PREV));
|
---|
83 | break;
|
---|
84 | case PAUSE_TRACK:
|
---|
85 | WinPostMsg(thisPtr->mfData->hwndPlayObject,WM_APPTERMINATENOTIFY, 0,MPFROMLONG(PAUSE_TRACK));
|
---|
86 | break;
|
---|
87 | case SEEK_TRACK:
|
---|
88 | WinPostMsg(thisPtr->mfData->hwndPlayObject,WM_APPTERMINATENOTIFY, MPFROMLONG(ulData), MPFROMLONG(SEEK_TRACK));
|
---|
89 | break;
|
---|
90 | default:
|
---|
91 | break;
|
---|
92 | }
|
---|
93 | return;
|
---|
94 | }
|
---|
95 |
|
---|
96 | MRESULT EXPENTRY playObjectProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
97 | {
|
---|
98 | switch (msg)
|
---|
99 | {
|
---|
100 | case WM_APPTERMINATENOTIFY:
|
---|
101 | {
|
---|
102 | THREADPARAMS* tPt=(THREADPARAMS*)WinQueryWindowULong(hwnd, QWL_USER);
|
---|
103 | HWND hwndFrame=tPt->hwndFrame;
|
---|
104 | CWMediaFolder *thisPtr=tPt->thisPtr;
|
---|
105 |
|
---|
106 | switch(LONGFROMMP(mp2))
|
---|
107 | {
|
---|
108 | case PLAY_FIRST:
|
---|
109 | TRY_LOUD(OBJECTPROC_FIRST) {
|
---|
110 | thisPtr->cwPlayAudioFile(hwndFrame, PLAY_FIRST);
|
---|
111 | }/* Try */
|
---|
112 | CATCH(OBJECTPROC_FIRST)
|
---|
113 | {
|
---|
114 | SysWriteToTrapLog("\nTrap occured in %s, file: %s, near line %d.\n",
|
---|
115 | __FUNCTION__, __FILE__, __LINE__);
|
---|
116 | } END_CATCH;
|
---|
117 | break;
|
---|
118 | case STOP_TRACK:
|
---|
119 | thisPtr->cwStopAudioFile(hwndFrame);
|
---|
120 | break;
|
---|
121 | case PLAY_NEXT:
|
---|
122 | TRY_LOUD(OBJECTPROC_NEXT) {
|
---|
123 | thisPtr->cwPlayAudioFile(hwndFrame, PLAY_NEXT);
|
---|
124 | }/* Try */
|
---|
125 | CATCH(OBJECTPROC_NEXT)
|
---|
126 | {
|
---|
127 | SysWriteToTrapLog("\nTrap occured in %s, file: %s, near line %d.\n",
|
---|
128 | __FUNCTION__, __FILE__, __LINE__);
|
---|
129 | } END_CATCH;
|
---|
130 | break;
|
---|
131 | case PLAY_PREV:
|
---|
132 | TRY_LOUD(OBJECTPROC_PREV) {
|
---|
133 | thisPtr->cwPlayAudioFile(hwndFrame, PLAY_PREV);
|
---|
134 | }/* Try */
|
---|
135 | CATCH(OBJECTPROC_PREV)
|
---|
136 | {
|
---|
137 | SysWriteToTrapLog("\nTrap occured in %s, file: %s, near line %d.\n",
|
---|
138 | __FUNCTION__, __FILE__, __LINE__);
|
---|
139 | } END_CATCH;
|
---|
140 | break;
|
---|
141 | case PAUSE_TRACK:
|
---|
142 | thisPtr->cwPauseAudioFile(hwndFrame);
|
---|
143 | break;
|
---|
144 | case SEEK_TRACK:
|
---|
145 | TRY_LOUD(OBJECTPROC_SEEK) {
|
---|
146 | thisPtr->cwSeekAudioFile(LONGFROMMP(mp1));
|
---|
147 | /* restart timer */
|
---|
148 | // WinStartTimer(WinQueryAnchorBlock(hwnd), WinWindowFromID(hwndFrame), IDTIMER_PLAY, PLAYTIMER_DELAY);
|
---|
149 | thisPtr->ulPos=LONGFROMMP(mp1)/1000;
|
---|
150 | }
|
---|
151 | CATCH(OBJECTPROC_SEEK)
|
---|
152 | {
|
---|
153 | SysWriteToTrapLog("\nTrap occured in %s, file: %s, near line %d.\n",
|
---|
154 | __FUNCTION__, __FILE__, __LINE__);
|
---|
155 | } END_CATCH;
|
---|
156 | break;
|
---|
157 | default:
|
---|
158 | break;
|
---|
159 | }/* switch() */
|
---|
160 | return (MRESULT)0;
|
---|
161 | }
|
---|
162 | default:
|
---|
163 | break;
|
---|
164 | }
|
---|
165 | return WinDefWindowProc( hwnd, msg, mp1, mp2);
|
---|
166 | }
|
---|
167 |
|
---|
168 | /* Every folder has one running play thread to handle play commands */
|
---|
169 | void _Optlink playThreadFunc (void *arg)
|
---|
170 | {
|
---|
171 | HAB hab;
|
---|
172 | HMQ hmq;
|
---|
173 | QMSG qmsg;
|
---|
174 | THREADPARAMS* tPt;
|
---|
175 | CWMediaFolder *thisPtr;
|
---|
176 |
|
---|
177 |
|
---|
178 | tPt=(THREADPARAMS*) arg;
|
---|
179 | if(!tPt)
|
---|
180 | return;
|
---|
181 | thisPtr=(CWMediaFolder*)tPt->thisPtr; //Pointer auf CWMediaFolder-Object
|
---|
182 | if(!somIsObj(thisPtr))
|
---|
183 | return;
|
---|
184 |
|
---|
185 | hab=WinInitialize(0);
|
---|
186 | if(hab) {
|
---|
187 | hmq=WinCreateMsgQueue(hab,0);
|
---|
188 | if(hmq) {
|
---|
189 | HWND hwnd;
|
---|
190 |
|
---|
191 | hwnd=WinCreateWindow(HWND_OBJECT,WC_STATIC,"MFObj",0,0,0,0,0,NULLHANDLE,HWND_BOTTOM,13343,NULL,NULL);
|
---|
192 | if(hwnd) {
|
---|
193 | thisPtr->mfData->hwndPlayObject=hwnd;
|
---|
194 | WinSetWindowULong(hwnd, QWL_USER,(ULONG)tPt);
|
---|
195 | WinSubclassWindow(hwnd,&playObjectProc);
|
---|
196 | /* Window created. */
|
---|
197 | while(WinGetMsg(hab,&qmsg,(HWND)NULL,0,0))
|
---|
198 | WinDispatchMsg(hab,&qmsg);
|
---|
199 |
|
---|
200 | WinDestroyWindow(hwnd);
|
---|
201 | }
|
---|
202 | WinDestroyMsgQueue(hmq);
|
---|
203 | }
|
---|
204 | WinTerminate(hab);
|
---|
205 | }
|
---|
206 | thisPtr->wpFreeMem((PBYTE)tPt);
|
---|
207 | thisPtr->mfData->hwndPlayObject=NULLHANDLE;
|
---|
208 | }
|
---|
209 |
|
---|
210 | void _Optlink rexxThreadFunc (void *arg)
|
---|
211 | {
|
---|
212 | HAB hab;
|
---|
213 | HMQ hmq;
|
---|
214 | QMSG qmsg;
|
---|
215 | CWMediaFolder *thisPtr;
|
---|
216 | HWND hwnd;
|
---|
217 | char *chrFileName;
|
---|
218 | char *chrFolderName;
|
---|
219 | char *chrRexxScript;
|
---|
220 | ULONG ulSize;
|
---|
221 | INSERTTRACKPARMS * threadParms;
|
---|
222 |
|
---|
223 | threadParms=(INSERTTRACKPARMS *)arg;
|
---|
224 | if(!threadParms)
|
---|
225 | return;
|
---|
226 |
|
---|
227 | thisPtr=(CWMediaFolder*)threadParms->thisPtr;
|
---|
228 |
|
---|
229 | if(!somIsObj(thisPtr))
|
---|
230 | return;
|
---|
231 |
|
---|
232 | if(!somIsObj(thisPtr->wpObjM3UFile)) {
|
---|
233 | thisPtr->wpFreeMem((PBYTE)threadParms);
|
---|
234 | return;
|
---|
235 | }
|
---|
236 |
|
---|
237 | chrFileName=thisPtr->wpAllocMem( CCHMAXPATH*3+10 , &ulSize);
|
---|
238 | if(!chrFileName) {
|
---|
239 | thisPtr->wpFreeMem((PBYTE)threadParms);
|
---|
240 | return;
|
---|
241 | }
|
---|
242 | chrFolderName=chrFileName+CCHMAXPATH+1;
|
---|
243 | chrRexxScript=chrFolderName+CCHMAXPATH+1;
|
---|
244 |
|
---|
245 | /* Get name of M3U file */
|
---|
246 | ulSize=CCHMAXPATH;
|
---|
247 | if(!((WPFileSystem*)thisPtr->wpObjM3UFile)->wpQueryRealName(chrFileName, &ulSize, TRUE))
|
---|
248 | return;
|
---|
249 |
|
---|
250 | /* Get name of folder */
|
---|
251 | ulSize=CCHMAXPATH;
|
---|
252 | if(!thisPtr->wpQueryRealName(chrFolderName, &ulSize, TRUE))
|
---|
253 | return;
|
---|
254 |
|
---|
255 | hab=WinInitialize(0);
|
---|
256 | if(hab) {
|
---|
257 | hmq=WinCreateMsgQueue(hab,0);
|
---|
258 | if(hmq) {
|
---|
259 | RXSTRING arg[2]; /* argument string for REXX */
|
---|
260 | RXSTRING rexxretval; /* return value from REXX */
|
---|
261 | APIRET rc; /* return code from REXX */
|
---|
262 | SHORT rexxrc = 0; /* return code from function */
|
---|
263 |
|
---|
264 | /* By setting the strlength of the output RXSTRING to zero, we */
|
---|
265 | /* force the interpreter to allocate memory and return it to us. */
|
---|
266 | /* We could provide a buffer for the interpreter to use instead. */
|
---|
267 | rexxretval.strlength = 0L; /* initialize return to empty*/
|
---|
268 |
|
---|
269 | MAKERXSTRING(arg[0], chrFileName, strlen(chrFileName));/* create input argument */
|
---|
270 | MAKERXSTRING(arg[1], chrFolderName, strlen(chrFolderName));/* create input argument */
|
---|
271 |
|
---|
272 | TRY_LOUD(RX_START) {
|
---|
273 | /* Here we call the interpreter. We don't really need to use */
|
---|
274 | /* all the casts in this call; they just help illustrate */
|
---|
275 | /* the data types used. */
|
---|
276 | rc=RexxStart((LONG) 2, /* number of arguments */
|
---|
277 | (PRXSTRING) &arg, /* array of arguments */
|
---|
278 | //(PSZ) chrRexxScript,/* name of REXX file */
|
---|
279 | (PSZ) threadParms->chrRexxScript,
|
---|
280 | // (PSZ) "H:\\cwmm\\mediafolder\\beep.cmd",/* name of REXX file */
|
---|
281 | (PRXSTRING) 0, /* No INSTORE used */
|
---|
282 | (PSZ) "CWRXX", /* Command env. name */
|
---|
283 | (LONG) RXSUBROUTINE, /* Code for how invoked */
|
---|
284 | (PRXSYSEXIT) 0, /* No EXITs on this call */
|
---|
285 | (PSHORT) &rexxrc, /* Rexx program output */
|
---|
286 | (PRXSTRING) &rexxretval ); /* Rexx program output */
|
---|
287 |
|
---|
288 | if(rc) {
|
---|
289 | sprintf(chrFileName,"Error in the Rexx skript %s\n\n Get more information with 'help REX%04d'.\n",
|
---|
290 | "", rc*-1);
|
---|
291 | WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, chrFileName, "", 1234, MB_OK|MB_MOVEABLE|MB_ERROR);
|
---|
292 | }
|
---|
293 | DosFreeMem(rexxretval.strptr); /* Release storage given to us by REXX. */
|
---|
294 | }
|
---|
295 | CATCH(RX_START)
|
---|
296 | {}END_CATCH;
|
---|
297 |
|
---|
298 | WinDestroyMsgQueue(hmq);
|
---|
299 | }
|
---|
300 | WinTerminate(hab);
|
---|
301 | }
|
---|
302 | // thisPtr->fContentsChanged=FALSE;
|
---|
303 | thisPtr->wpFreeMem((PBYTE)chrFileName);
|
---|
304 | thisPtr->wpFreeMem((PBYTE)threadParms);
|
---|
305 | }
|
---|
306 |
|
---|
307 | ULONG CWMediaFolder::cwQueryMFldrFlags(void)
|
---|
308 | {
|
---|
309 | return ulPrivFlags;
|
---|
310 | }
|
---|
311 |
|
---|
312 | BOOL CWMediaFolder::cwUnshrinkFolder(HWND hwndFrame)
|
---|
313 | {
|
---|
314 | HWND hwndCnr;
|
---|
315 | if((hwndCnr=WinWindowFromID(hwndFrame, FID_CLIENT))!=NULLHANDLE)
|
---|
316 | {
|
---|
317 | SWP swp, swp2, swp3;
|
---|
318 | POINTL ptl;
|
---|
319 |
|
---|
320 | /* Get container size */
|
---|
321 | WinQueryWindowPos(hwndCnr, &swp);
|
---|
322 | if(swp.cy==0) {
|
---|
323 | /* Container is shrinked so unshrink it */
|
---|
324 | WinSetWindowULong(hwndFrame, QWL_STYLE, (WinQueryWindowULong(hwndFrame, QWL_STYLE) & ~FS_DLGBORDER)|FS_SIZEBORDER);
|
---|
325 | WinSetWindowPos(hwndFrame, NULLHANDLE, swpUnshrink.x, swpUnshrink.y, swpUnshrink.cx,swpUnshrink.cy,SWP_SIZE|SWP_MOVE);
|
---|
326 | return TRUE;
|
---|
327 | }
|
---|
328 | }
|
---|
329 | return FALSE;
|
---|
330 | }
|
---|
331 |
|
---|
332 |
|
---|
333 | /**************************************************************/
|
---|
334 | /* */
|
---|
335 | /* Shrink the folder so only the play control is visible. */
|
---|
336 | /* */
|
---|
337 | /**************************************************************/
|
---|
338 | BOOL CWMediaFolder::cwShrinkFolderToCompact(HWND hwndFrame)
|
---|
339 | {
|
---|
340 | HWND hwndCnr;
|
---|
341 | if((hwndCnr=WinWindowFromID(hwndFrame, FID_CLIENT))!=NULLHANDLE)
|
---|
342 | {
|
---|
343 | SWP swp, swp2, swp3;
|
---|
344 | POINTL ptl;
|
---|
345 | char chrText[20];
|
---|
346 | WinQueryWindowPos(hwndFrame, &swp2);
|
---|
347 | /* Save size for unshrinking */
|
---|
348 | swpUnshrink=swp2;
|
---|
349 | /* Get container size */
|
---|
350 | WinQueryWindowPos(hwndCnr, &swp);
|
---|
351 | if(swp.cy>0) {
|
---|
352 | /* Shrink folder to hide container */
|
---|
353 | swp2.y+=swp.cy;
|
---|
354 | swp2.cy-=swp.cy;
|
---|
355 | /* Get size of statusline */
|
---|
356 | // WinQueryWindowPos(bottomControlFromFrameHWND(hwndFrame), &swp);
|
---|
357 | // WinSetWindowPos(bottomControlFromFrameHWND(hwndFrame), NULLHANDLE, 0,0,swp.cx, 0, SWP_SIZE);
|
---|
358 | /* Shrink folder to hide status line */
|
---|
359 | //swp2.y+=swp.cy;
|
---|
360 | //swp2.cy-=swp.cy;
|
---|
361 | /* Get size of control area at the top */
|
---|
362 | WinQueryWindowPos(topControlFromFrameHWND(hwndFrame), &swp);
|
---|
363 | /* Get size of the play control area */
|
---|
364 | WinQueryWindowPos(playControlDialogFromFrameHWND(hwndFrame), &swp3);
|
---|
365 | swp2.cx-=(swp.cx-swp3.cx)+10;
|
---|
366 |
|
---|
367 | /* DLGBORDER is smaller than a size border */
|
---|
368 | WinSendMsg(hwndFrame, WM_QUERYBORDERSIZE, &ptl, 0L);
|
---|
369 | swp2.y+=2*(ptl.y-WinQuerySysValue(HWND_DESKTOP, SV_CYDLGFRAME))+2;
|
---|
370 | swp2.cy-=2*(ptl.y-WinQuerySysValue(HWND_DESKTOP, SV_CYDLGFRAME))+2;
|
---|
371 | WinSetWindowULong(hwndFrame, QWL_STYLE, (WinQueryWindowULong(hwndFrame, QWL_STYLE) & ~FS_SIZEBORDER)|FS_DLGBORDER);
|
---|
372 |
|
---|
373 | WinSetWindowPos(hwndFrame, NULLHANDLE, swp2.x, swp2.y, swp2.cx,swp2.cy,SWP_SIZE|SWP_MOVE);
|
---|
374 | /*
|
---|
375 | By changing the to contents view we trick the WPS to show the 'Details view' menu item in
|
---|
376 | the view menu of the folders system menu. In that sub menu the WPS always inserts all known
|
---|
377 | views a user may switch to. Tree and contents view are removed in the
|
---|
378 | frame proc. Compact view will not be inserted if already in compact view (see wpModifyPopupMenu()).
|
---|
379 | The system knows nothing about the 'compact view' and all the handling is done by us.
|
---|
380 | As a side effect the folder position information for the details
|
---|
381 | view isn't changed when the folder is closed in 'Compact view'.
|
---|
382 | */
|
---|
383 | wpMenuItemSelected(hwndFrame, 0x2cc);
|
---|
384 |
|
---|
385 | /* Change the view name shown in the title */
|
---|
386 | getMessage(chrText, IDSTR_VIEWCOMPACT, sizeof(chrText), queryResModuleHandle(),hwndFrame);
|
---|
387 | wpRegisterView(hwndFrame, chrText);
|
---|
388 | }
|
---|
389 | return TRUE;
|
---|
390 | }
|
---|
391 | return FALSE;
|
---|
392 | }
|
---|
393 |
|
---|
394 | BOOL CWMediaFolder::cwInsertAllTracks(char* chrM3UFile)
|
---|
395 | {
|
---|
396 | INSERTTRACKPARMS * threadParms;
|
---|
397 | ULONG ulError;
|
---|
398 |
|
---|
399 | if((threadParms=(INSERTTRACKPARMS*)wpAllocMem(sizeof(INSERTTRACKPARMS), &ulError))==NULLHANDLE)
|
---|
400 | return FALSE;
|
---|
401 | threadParms->thisPtr=this;
|
---|
402 | sprintf(threadParms->chrRexxScript,"%s%s", chrInstallDir, RX_INSERT_MEDIAFLDRTRACKS);
|
---|
403 |
|
---|
404 | _beginthread(rexxThreadFunc,NULL,8192*16,(void*)threadParms); //Fehlerbehandlung fehlt
|
---|
405 | return TRUE;
|
---|
406 | }
|
---|
407 |
|
---|
408 | void CWMediaFolder::cwSetStatusLineText(char * chrText)
|
---|
409 | {
|
---|
410 |
|
---|
411 | if(!chrText) {
|
---|
412 | char text[100]="";
|
---|
413 | char text2[100]="";
|
---|
414 | char time[50];
|
---|
415 | char chrBuf[2];
|
---|
416 |
|
---|
417 | if(mfData) {
|
---|
418 | PrfQueryProfileString(HINI_USER, "PM_Default_National", "sThousand",
|
---|
419 | ",", chrBuf, sizeof(chrBuf));
|
---|
420 | chrBuf[sizeof(chrBuf)-1]=0;
|
---|
421 |
|
---|
422 | if(mfData->ulTotalTime<=3600) {
|
---|
423 | getMessage( text, IDSTR_STATUSTIME1, sizeof(text), queryResModuleHandle(), HWND_DESKTOP);
|
---|
424 | sprintf(time, text, mfData->ulTotalTime/60, mfData->ulTotalTime%60);
|
---|
425 | }
|
---|
426 | else if(mfData->ulTotalTime<=3600*24) {
|
---|
427 | getMessage( text, IDSTR_STATUSTIME2, sizeof(text), queryResModuleHandle(),HWND_DESKTOP);
|
---|
428 | sprintf(time, text, mfData->ulTotalTime/3600, (mfData->ulTotalTime%3600)/60, mfData->ulTotalTime%60);
|
---|
429 | }
|
---|
430 | else {
|
---|
431 | getMessage( text, IDSTR_STATUSTIME3, sizeof(text), queryResModuleHandle(),HWND_DESKTOP);
|
---|
432 | sprintf(time, text, mfData->ulTotalTime/(3600*24),
|
---|
433 | (mfData->ulTotalTime%(3600*24))/3600, (mfData->ulTotalTime%3600)/60, mfData->ulTotalTime%60);
|
---|
434 | }
|
---|
435 | if(mfData->ulSize<=0xffffffff) {
|
---|
436 | getMessage( text2, IDSTR_STATUSTIME4, sizeof(text2), queryResModuleHandle(),HWND_DESKTOP);
|
---|
437 | sprintf(text, text2,
|
---|
438 | mfData->ulNumTracks, mfData->ulSize/1000000 ,chrBuf, (mfData->ulSize%1000000)/1000,
|
---|
439 | chrBuf, mfData->ulSize%1000,
|
---|
440 | time);
|
---|
441 | }
|
---|
442 | else {
|
---|
443 | getMessage( text2, IDSTR_STATUSTIME5, sizeof(text2), queryResModuleHandle(),HWND_DESKTOP);
|
---|
444 | sprintf(text, text2, mfData->ulNumTracks);
|
---|
445 | }
|
---|
446 | }
|
---|
447 | WinSetWindowText(WinWindowFromID(hwndBottom, IDST_STATUSTEXT),text);
|
---|
448 | }
|
---|
449 | else
|
---|
450 | WinSetWindowText(WinWindowFromID(hwndBottom, IDST_STATUSTEXT),chrText);
|
---|
451 | }
|
---|
452 |
|
---|
453 | MMAudio* CWMediaFolder::cwQueryCurrentlyPlayingObject(void)
|
---|
454 | {
|
---|
455 | return (MMAudio*)currentObject;
|
---|
456 | }
|
---|
457 |
|
---|
458 | BOOL CWMediaFolder::cwAddToolbarOptionPage(HWND hwndNotebook)
|
---|
459 | {
|
---|
460 | PAGEINFO pageinfo;
|
---|
461 | char pageName[100];
|
---|
462 |
|
---|
463 | //Clear the pageinfo structure
|
---|
464 | memset((PCH)&pageinfo, 0, sizeof(PAGEINFO));
|
---|
465 | //Fill the pageinfo structure
|
---|
466 | pageinfo.cb = sizeof(PAGEINFO);
|
---|
467 | pageinfo.hwndPage = NULLHANDLE;
|
---|
468 | pageinfo.usPageStyleFlags = BKA_MAJOR | BKA_STATUSTEXTON;
|
---|
469 | pageinfo.usPageInsertFlags = BKA_FIRST;
|
---|
470 | //We want page numbers
|
---|
471 | pageinfo.usSettingsFlags = SETTINGS_PAGE_NUMBERS;
|
---|
472 | //The dialog procedure for this page
|
---|
473 | pageinfo.pfnwp = settingsToolbarOptionDlgProc;
|
---|
474 | //The resource DLL
|
---|
475 | pageinfo.resid = queryResModuleHandle();
|
---|
476 | //pageinfo.resid = queryModuleHandle();
|
---|
477 | //The ID of the dialog template
|
---|
478 | pageinfo.dlgid = IDDLG_TOOLBARSETTINGS;
|
---|
479 | //We need a pointer to our WPS-object in the dialog procedure
|
---|
480 | //to call class functions
|
---|
481 | pageinfo.pCreateParams = this;
|
---|
482 | //The ID of the help panel for this page
|
---|
483 | //pageinfo.idDefaultHelpPanel = 2000;
|
---|
484 | //Tell the WPS the help library name
|
---|
485 | //pageinfo.pszHelpLibraryName = AFHELPLIBRARY;
|
---|
486 | //We have a major tab so we need a name
|
---|
487 | /* pageName: "General" */
|
---|
488 | getMessage(pageName, IDSTRSETTING_TOOLBAR, sizeof(pageName), queryResModuleHandle(), hwndNotebook);
|
---|
489 | pageinfo.pszName = pageName;
|
---|
490 |
|
---|
491 | //Insert the page into the settings notebook
|
---|
492 | return wpInsertSettingsPage(hwndNotebook,&pageinfo);
|
---|
493 | }
|
---|
494 |
|
---|
495 | BOOL mmGetOtherPlayingAudioFile( CWMediaFolder * mediaFolder, HWND hwndContainer, WPObject** wpObject, PMINIRECORDCORE* pmrc)
|
---|
496 | {
|
---|
497 | PMINIRECORDCORE mrc;
|
---|
498 | WPObject * contentObject;
|
---|
499 |
|
---|
500 | /* See if we have an audio file played with doubleclick */
|
---|
501 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORDEMPHASIS,MPFROMLONG(CMA_FIRST),
|
---|
502 | MPFROMSHORT(CRA_INUSE));
|
---|
503 | if(mrc) {
|
---|
504 | SOMClass *cwAudioClass=somhlpGetSomClass("MMAudio");
|
---|
505 | contentObject=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object
|
---|
506 | if(somIsObj(contentObject) && somIsObj(cwAudioClass)) {
|
---|
507 | if((contentObject=mediaFolder->cwGetFileSystemObject(contentObject))!=NULLHANDLE) {
|
---|
508 | /* Check if it's an audio file thus playable */
|
---|
509 | if(contentObject->somIsA(cwAudioClass)) {
|
---|
510 | if(((MMAudio*)contentObject)->wpQueryDefaultView()==0xbbf9){
|
---|
511 | /* If stop menu is default, this means the track is playing. */
|
---|
512 | *wpObject=contentObject;
|
---|
513 | *pmrc=mrc;
|
---|
514 | return TRUE;
|
---|
515 | };
|
---|
516 | }
|
---|
517 | }
|
---|
518 | }/* somIsObj() */
|
---|
519 | }
|
---|
520 | return FALSE;
|
---|
521 | }
|
---|
522 |
|
---|
523 | ULONG CWMediaFolder::cwPlayAudioFile(HWND hwndFrame, ULONG ulWhich)
|
---|
524 | {
|
---|
525 | HWND hwndContainer;
|
---|
526 | PMINIRECORDCORE mrc, mrcTemp;
|
---|
527 | WPObject * contentObject;
|
---|
528 | SOMClass *mmMIDIClass;
|
---|
529 | SOMClass *cwAudioClass=somhlpGetSomClass("MMAudio");
|
---|
530 |
|
---|
531 | char name[CCHMAXPATH];
|
---|
532 | ULONG ulNameSize;
|
---|
533 | char chrCommand[CCHMAXPATH*2];
|
---|
534 | char chrDevice[30];
|
---|
535 | char retMsg[20];
|
---|
536 | ULONG rc;
|
---|
537 | int iWavePriv;
|
---|
538 | int iTime2;
|
---|
539 | HWND hwndNotify;
|
---|
540 |
|
---|
541 | if(ulFlags&FLAG_RANDOM)
|
---|
542 | return cwPlayRandomAudioFile( hwndFrame);
|
---|
543 |
|
---|
544 | hwndContainer=WinWindowFromID(hwndFrame, FID_CLIENT);
|
---|
545 | if(!WinIsWindow(WinQueryAnchorBlock(hwndFrame), hwndContainer))
|
---|
546 | return 0;
|
---|
547 |
|
---|
548 | /* Get class object */
|
---|
549 | mmMIDIClass=somhlpGetSomClass("MMMIDI");
|
---|
550 |
|
---|
551 | /* Get new ID for wave device */
|
---|
552 | if(cwRequestMutex(hmtxFileName, 100000)==ERROR_TIMEOUT)
|
---|
553 | return FALSE;
|
---|
554 |
|
---|
555 | iWaveDev++;
|
---|
556 | if(iWaveDev==1000)
|
---|
557 | iWaveDev=1;
|
---|
558 | iWavePriv=iWaveDev;
|
---|
559 | cwReleaseMutex(hmtxFileName);
|
---|
560 | BOOL notFound;
|
---|
561 |
|
---|
562 | switch(ulWhich) {
|
---|
563 | case PLAY_FIRST:
|
---|
564 | {
|
---|
565 | WPObject *wpObject;
|
---|
566 | PMINIRECORDCORE pmrc;
|
---|
567 |
|
---|
568 | #if 0
|
---|
569 | /* There's already a file playing using doubleclick */
|
---|
570 | if(mmGetOtherPlayingAudioFile( this, hwndContainer, &wpObject, &pmrc))
|
---|
571 | return 0;
|
---|
572 | #endif
|
---|
573 |
|
---|
574 | /* Get first selected container item of our folder */
|
---|
575 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORDEMPHASIS, MPFROMSHORT(CMA_FIRST),
|
---|
576 | MPFROMSHORT(CRA_SELECTED));
|
---|
577 |
|
---|
578 | if(iWave!=0 && mrc && (int)mrc!=-1) {
|
---|
579 | cwStopAudioFile(hwndFrame);
|
---|
580 | return cwPlayAudioFile(hwndFrame, PLAY_FIRST);
|
---|
581 | }
|
---|
582 |
|
---|
583 | if(!mrc || (int)mrc==-1)
|
---|
584 | /* Get first container item of our folder */
|
---|
585 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD,NULL,
|
---|
586 | MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
|
---|
587 |
|
---|
588 | if(!mrc || (int)mrc==-1)
|
---|
589 | return 0;
|
---|
590 |
|
---|
591 | notFound=TRUE;
|
---|
592 | do {
|
---|
593 | contentObject=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object
|
---|
594 | if(somIsObj(contentObject)) {
|
---|
595 | /* Get file system object or NULL */
|
---|
596 | if((contentObject=cwGetFileSystemObject(contentObject))==NULLHANDLE) {
|
---|
597 | // HlpWriteToTrapLog("Tried to resolve shadow, no success, continue...\n");
|
---|
598 | /* Try next object */
|
---|
599 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD, mrc,
|
---|
600 | MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
|
---|
601 | // HlpWriteToTrapLog("New mrc: %x\n", mrc);
|
---|
602 | continue;
|
---|
603 | }
|
---|
604 | }
|
---|
605 | else
|
---|
606 | return 0;/* Error */
|
---|
607 |
|
---|
608 | if( contentObject->somIsA(cwAudioClass) ||
|
---|
609 | /*contentObject->somIsA(mmAudioClass) ||*/
|
---|
610 | contentObject->somIsA(mmMIDIClass)) {
|
---|
611 | notFound=FALSE;
|
---|
612 | /* Get the name of the audio file */
|
---|
613 | ulNameSize=sizeof(name);
|
---|
614 | ((WPFileSystem*)contentObject)->wpQueryRealName(name,&ulNameSize,TRUE);
|
---|
615 | }
|
---|
616 | else
|
---|
617 | {
|
---|
618 | /* Try next object */
|
---|
619 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD, mrc,
|
---|
620 | MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
|
---|
621 | }
|
---|
622 | }while(notFound && mrc && (int)mrc!=-1);
|
---|
623 | // HlpWriteToTrapLog("Left loop...\n");
|
---|
624 | break;
|
---|
625 | }
|
---|
626 | case PLAY_NEXT:
|
---|
627 |
|
---|
628 | mrcTemp=mrcPlaying;
|
---|
629 |
|
---|
630 | if(iWave==0) {
|
---|
631 | WPObject *wpObject;
|
---|
632 | PMINIRECORDCORE pmrc;
|
---|
633 |
|
---|
634 | if(mmGetOtherPlayingAudioFile( this, hwndContainer, &wpObject, &pmrc)) {
|
---|
635 | mrcTemp=pmrc;
|
---|
636 | }
|
---|
637 | else
|
---|
638 | return cwPlayAudioFile(hwndFrame, PLAY_FIRST);/* Not yet playing */
|
---|
639 | }
|
---|
640 |
|
---|
641 | /* Get next container item of our folder */
|
---|
642 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD,mrcTemp,
|
---|
643 | MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
|
---|
644 |
|
---|
645 | if((int)mrc==-1) {
|
---|
646 | /* Wrong parameter -> user deleted the shadow. */
|
---|
647 | /* Stop wave, remove in use emphasis. */
|
---|
648 | cwStopAudioFile(hwndFrame);
|
---|
649 | return 0;
|
---|
650 | }
|
---|
651 | // HlpWriteToTrapLog("Next mrc is %x\n", mrc);
|
---|
652 |
|
---|
653 | notFound=TRUE;
|
---|
654 | while(notFound && mrc && (int)mrc!=-1){
|
---|
655 | contentObject=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object
|
---|
656 | if(somIsObj(contentObject)) {
|
---|
657 | /* Get file system object or NULL */
|
---|
658 | if((contentObject=cwGetFileSystemObject(contentObject))==NULLHANDLE) {
|
---|
659 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD, mrc,
|
---|
660 | MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
|
---|
661 | continue;
|
---|
662 | }
|
---|
663 | }
|
---|
664 | else
|
---|
665 | return 0;/* Error */
|
---|
666 |
|
---|
667 | if(contentObject->somIsA(cwAudioClass) ||
|
---|
668 | /* contentObject->somIsA(mmAudioClass) || */
|
---|
669 | contentObject->somIsA(mmMIDIClass)) {
|
---|
670 | notFound=FALSE;
|
---|
671 | ulNameSize=sizeof(name);
|
---|
672 | ((WPFileSystem*)contentObject)->wpQueryRealName(name,&ulNameSize,TRUE);
|
---|
673 | }
|
---|
674 | else
|
---|
675 | {
|
---|
676 | /* Try next object */
|
---|
677 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD, mrc,
|
---|
678 | MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
|
---|
679 | }
|
---|
680 | };
|
---|
681 | cwStopAudioFile(hwndFrame);
|
---|
682 | if(!mrc) {
|
---|
683 | if(ulFlags & FLAG_REPEAT)
|
---|
684 | return cwPlayAudioFile(hwndFrame, PLAY_FIRST);
|
---|
685 | else
|
---|
686 | return 0;
|
---|
687 | }
|
---|
688 | break;
|
---|
689 | case PLAY_PREV:
|
---|
690 |
|
---|
691 | mrcTemp=mrcPlaying;
|
---|
692 | /* We are currently playing? */
|
---|
693 | if(iWave==0) {
|
---|
694 | #if 0
|
---|
695 | WPObject *wpObject;
|
---|
696 | PMINIRECORDCORE pmrc;
|
---|
697 | /* Check if there's a playing file started by the user */
|
---|
698 | if(mmGetOtherPlayingAudioFile( this, hwndContainer, &wpObject, &pmrc)) {
|
---|
699 | mrcTemp=pmrc;
|
---|
700 | cwStopAudioFile(hwndFrame);
|
---|
701 | /* Select the object */
|
---|
702 | WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(pmrc),
|
---|
703 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
704 |
|
---|
705 | return cwPlayAudioFile(hwndFrame, PLAY_FIRST);/* Not yet playing, so start the first one. */
|
---|
706 | }
|
---|
707 | else
|
---|
708 | #endif
|
---|
709 | return cwPlayAudioFile(hwndFrame, PLAY_FIRST);/* Not yet playing, so start the first one. */
|
---|
710 | }
|
---|
711 |
|
---|
712 | /* Check the current time. If we are at the very beginning of the track skip to the previous track
|
---|
713 | otherwise skip to the beginning of the current track. */
|
---|
714 | if(ulPos<=2) {
|
---|
715 | /* Get previous container item of our folder */
|
---|
716 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD,mrcTemp,
|
---|
717 | MPFROM2SHORT(CMA_PREV,CMA_ITEMORDER));
|
---|
718 | }
|
---|
719 | else
|
---|
720 | mrc=NULLHANDLE;
|
---|
721 |
|
---|
722 | cwStopAudioFile(hwndFrame);
|
---|
723 |
|
---|
724 | if(!mrc)
|
---|
725 | mrc=mrcTemp;
|
---|
726 |
|
---|
727 | /* Find an audio file */
|
---|
728 | notFound=TRUE;
|
---|
729 | while(notFound && mrc && (int)mrc!=-1){
|
---|
730 | contentObject=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object
|
---|
731 | if(somIsObj(contentObject)) {
|
---|
732 | /* Get file system object or NULL */
|
---|
733 | if((contentObject=cwGetFileSystemObject(contentObject))==NULLHANDLE) {
|
---|
734 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD, mrc,
|
---|
735 | MPFROM2SHORT(CMA_PREV,CMA_ITEMORDER));
|
---|
736 | continue;
|
---|
737 | }
|
---|
738 | }
|
---|
739 | else
|
---|
740 | return 0;/* Error!! */
|
---|
741 |
|
---|
742 | /* Check if it's an audio file thus playable */
|
---|
743 | if(contentObject->somIsA(cwAudioClass) ||
|
---|
744 | /* contentObject->somIsA(mmAudioClass) || */
|
---|
745 | contentObject->somIsA(mmMIDIClass)) {
|
---|
746 | notFound=FALSE;
|
---|
747 | ulNameSize=sizeof(name);
|
---|
748 | ((WPFileSystem*)contentObject)->wpQueryRealName(name,&ulNameSize,TRUE);
|
---|
749 | }
|
---|
750 | else
|
---|
751 | /* Try next object */
|
---|
752 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD, mrc,
|
---|
753 | MPFROM2SHORT(CMA_PREV,CMA_ITEMORDER));
|
---|
754 | };
|
---|
755 | if(!mrc)
|
---|
756 | return 0;
|
---|
757 |
|
---|
758 | break;
|
---|
759 | default:
|
---|
760 | return 0;
|
---|
761 | }
|
---|
762 |
|
---|
763 | /* Found a valid object. Now play it. */
|
---|
764 |
|
---|
765 | if(!getMessage(chrCommand, IDSTR_STARTINGTRACK, sizeof(chrCommand), queryResModuleHandle(), hwndFrame))
|
---|
766 | sprintf(chrCommand, "Starting track...");
|
---|
767 | setPlayTimeText2(this, chrCommand);
|
---|
768 |
|
---|
769 | if(contentObject->somIsA(mmMIDIClass))
|
---|
770 | strncpy(chrDevice,"SEQUENCER", sizeof(chrDevice) - 1);
|
---|
771 | else /*if(contentObject->somIsA(cwAudioClass) || contentObject->somIsA(mmAudioClass))*/
|
---|
772 | strncpy(chrDevice,"WAVEAUDIO", sizeof(chrDevice));
|
---|
773 |
|
---|
774 | chrDevice[sizeof(chrDevice)-1]=0;
|
---|
775 |
|
---|
776 | hwndNotify=playControlDialogFromFrameHWND(hwndFrame);//WinWindowFromID(hwndTop, IDDLG_TOPMIDDLE);
|
---|
777 |
|
---|
778 | /* Start audio file */
|
---|
779 | sprintf(chrCommand,"open \"%s\" type %s alias wave%d SHAREABLE wait",name, chrDevice, iWavePriv);
|
---|
780 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), hwndNotify, 0);
|
---|
781 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS)
|
---|
782 | return 0;
|
---|
783 |
|
---|
784 | /* Set time format */
|
---|
785 | sprintf(chrCommand,"SET wave%d TIME FORMAT MILLISECONDS wait", iWavePriv);
|
---|
786 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
787 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
788 | sprintf(chrCommand,"close wave%d wait",iWavePriv);
|
---|
789 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
790 | return 0;
|
---|
791 | }
|
---|
792 |
|
---|
793 | sprintf(chrCommand,"SETPOSITIONADVISE wave%d ON EVERY 1000 notify", iWavePriv);
|
---|
794 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg),hwndNotify, 0);
|
---|
795 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
796 | sprintf(chrCommand,"close wave%d wait",iWavePriv);
|
---|
797 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
798 | return 0;
|
---|
799 | }
|
---|
800 |
|
---|
801 | /* Get wave length in ms */
|
---|
802 | sprintf(chrCommand,"STATUS wave%d LENGTH WAIT", iWavePriv);
|
---|
803 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
804 | if((rc & 0x0000ffff)==MCIERR_SUCCESS) {
|
---|
805 | iTime2=atoi(retMsg);
|
---|
806 | sprintf(chrCommand,"%d:%02d %d:%02d -%d:%02d",iTime2/1000/60,(iTime2/1000)%60,
|
---|
807 | 0, 0,
|
---|
808 | iTime2/1000/60,(iTime2/1000)%60);
|
---|
809 | // WinSetWindowText(WinWindowFromID(hwndTop, IDST_PLAYTIME), chrCommand);
|
---|
810 | // WinSetWindowText(playTimeControlFromFrameHWND(hwndFrame), chrCommand);
|
---|
811 | }
|
---|
812 | ulTotalLength=iTime2;
|
---|
813 |
|
---|
814 | /* Set volume */
|
---|
815 | sprintf(chrCommand,"SET wave%d AUDIO VOLUME %d wait", iWavePriv, ulVolume);
|
---|
816 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
817 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
818 | sprintf(chrCommand,"close wave%d",iWavePriv);
|
---|
819 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
820 | return 0;
|
---|
821 | }
|
---|
822 |
|
---|
823 | sprintf(chrCommand,"play wave%d FROM 0", iWavePriv);
|
---|
824 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
825 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
826 | sprintf(chrCommand,"close wave%d",iWavePriv);
|
---|
827 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
828 | return 0;
|
---|
829 | }
|
---|
830 |
|
---|
831 | /* Start pos timer. SET MCIPOSITIONADVICE fails when seeking in the wave.
|
---|
832 | Don't know why. */
|
---|
833 |
|
---|
834 | //WinStartTimer(WinQueryAnchorBlock(hwndFrame), WinWindowFromID(hwndTop, IDDLG_TOPMIDDLE), IDTIMER_PLAY, PLAYTIMER_DELAY);
|
---|
835 | WinStartTimer(WinQueryAnchorBlock(hwndFrame), playControlDialogFromFrameHWND(hwndFrame), IDTIMER_PLAY, PLAYTIMER_DELAY);
|
---|
836 |
|
---|
837 | /* Set emphasis by adding the object to the inuse list */
|
---|
838 | memset(&myViewItem, 0,sizeof(myViewItem));
|
---|
839 | myViewItem.useItem.type=USAGE_OPENVIEW;
|
---|
840 | myViewItem.viewItem.view=OPEN_PLAYING;
|
---|
841 |
|
---|
842 | //WPObject* wpObject=cwGetFileSystemObject(tempObject);
|
---|
843 | WPObject* wpObject=contentObject;
|
---|
844 |
|
---|
845 | if(wpObject->wpAddToObjUseList(&myViewItem.useItem))
|
---|
846 | {
|
---|
847 | myViewItem.bIsInUseList=TRUE;
|
---|
848 | };
|
---|
849 | /* Select the object */
|
---|
850 | WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(mrc),
|
---|
851 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
852 |
|
---|
853 | iWave=iWavePriv;
|
---|
854 | currentObject=wpObject;
|
---|
855 | mrcPlaying=mrc;
|
---|
856 | /* The start position of the play command */
|
---|
857 | ulStartPosition=0;
|
---|
858 | ulPos=0;
|
---|
859 | bPaused=FALSE;
|
---|
860 | /* Set time display */
|
---|
861 | setPlayTimeText(this);
|
---|
862 | return 0;
|
---|
863 | }
|
---|
864 |
|
---|
865 | //#define RANDOM_DEBUG
|
---|
866 |
|
---|
867 | static int _getRandomTrack( MEDIAFLDRDATA* mfData)
|
---|
868 | {
|
---|
869 | int zufall = 0;
|
---|
870 | DATETIME DT;
|
---|
871 | INT seed, start, iCheck=0;
|
---|
872 | BOOL bFound=FALSE;
|
---|
873 |
|
---|
874 | /** Get a random number in the appropriate range */
|
---|
875 | DosGetDateTime((PDATETIME)&DT); /* Get the time */
|
---|
876 | seed = DT.hours*60 + DT.minutes; /* convert to hundreths */
|
---|
877 | seed = seed*60 + DT.seconds;
|
---|
878 | seed = seed*100 + DT.hundredths;
|
---|
879 | srand((INT)seed); /* Set random number seed */
|
---|
880 | start=zufall;
|
---|
881 |
|
---|
882 | while(!bFound) {
|
---|
883 | zufall=rand()%mfData->iNumToPlay; /* Range is 0...iNumToPlay-1 */
|
---|
884 | iCheck++;
|
---|
885 |
|
---|
886 | #ifdef RANDOM_DEBUG
|
---|
887 | HlpWriteToTrapLog("\n Zufall: %d %d\n", zufall, mfData->pRandomArray[zufall]);
|
---|
888 | #endif
|
---|
889 | /* Get a random number in the appropriate range */
|
---|
890 | if(mfData->pRandomArray[zufall]==0) {
|
---|
891 | mfData->pRandomArray[zufall]=1;
|
---|
892 | #ifdef RANDOM_DEBUG
|
---|
893 | HlpWriteToTrapLog("2 Zufall: %d %d\n", zufall, mfData->pRandomArray[zufall]);
|
---|
894 | #endif
|
---|
895 | return zufall;
|
---|
896 | }
|
---|
897 |
|
---|
898 | /* Already played number. Find another */
|
---|
899 | #if 0
|
---|
900 | if (zufall == start && !bFound) {
|
---|
901 | #ifdef RANDOM_DEBUG
|
---|
902 | HlpWriteToTrapLog("Error Zufall: %d %d\n", zufall, mfData->pRandomArray[zufall]);
|
---|
903 | #endif
|
---|
904 | return -1;
|
---|
905 | }
|
---|
906 | #endif
|
---|
907 |
|
---|
908 | if(iCheck>MAX_RANDOM_OBJECTS)
|
---|
909 | break; /* Emergency exit... */
|
---|
910 | };
|
---|
911 | return -1; /* Error */
|
---|
912 | }
|
---|
913 |
|
---|
914 | ULONG CWMediaFolder::cwPlayRandomAudioFile(HWND hwndFrame)
|
---|
915 | {
|
---|
916 | HWND hwndContainer;
|
---|
917 | PMINIRECORDCORE mrc, mrcTemp;
|
---|
918 | WPObject * contentObject;
|
---|
919 | /* SOMClass *mmAudioClass; */
|
---|
920 | SOMClass *mmMIDIClass;
|
---|
921 | SOMClass *cwAudioClass=somhlpGetSomClass("MMAudio");
|
---|
922 |
|
---|
923 | char name[CCHMAXPATH];
|
---|
924 | ULONG ulNameSize;
|
---|
925 | char chrCommand[CCHMAXPATH*2];
|
---|
926 | char chrDevice[30];
|
---|
927 | char retMsg[20];
|
---|
928 | ULONG rc;
|
---|
929 | int iWavePriv;
|
---|
930 | int iTime2 = 0;
|
---|
931 | HWND hwndNotify;
|
---|
932 | BOOL notFound;
|
---|
933 | int iTrack,a;
|
---|
934 |
|
---|
935 | #ifdef RANDOM_DEBUG
|
---|
936 | HlpWriteToTrapLog("Entering %s\n", __FUNCTION__);
|
---|
937 | #endif
|
---|
938 |
|
---|
939 | #ifdef RANDOM_DEBUG_2
|
---|
940 | HlpWriteToTrapLog("%s mfData: %x\n", __FUNCTION__, mfData);
|
---|
941 | HlpWriteToTrapLog("%s random array: %x\n", __FUNCTION__, mfData->pRandomArray);
|
---|
942 | #endif
|
---|
943 |
|
---|
944 | /* Check if we currently play the last track. */
|
---|
945 | if((mfData->iNumPlayed>=mfData->iNumToPlay) && mfData->pRandomArray) {
|
---|
946 | cwStopAudioFile(hwndFrame);/* Reset playing vars and remove in use emphasis */
|
---|
947 | if(!(ulFlags&FLAG_REPEAT))
|
---|
948 | return 0;
|
---|
949 | }
|
---|
950 |
|
---|
951 | hwndContainer=WinWindowFromID(hwndFrame, FID_CLIENT);
|
---|
952 | if(!WinIsWindow(WinQueryAnchorBlock(hwndFrame), hwndContainer))
|
---|
953 | return 0;
|
---|
954 |
|
---|
955 | /* Get class object */
|
---|
956 | // mmAudioClass=queryMMAudioClass();
|
---|
957 | mmMIDIClass=somhlpGetSomClass("MMMIDI");
|
---|
958 |
|
---|
959 | /* Get new ID for wave device */
|
---|
960 | if(cwRequestMutex(hmtxFileName, 100000)==ERROR_TIMEOUT)
|
---|
961 | return FALSE;
|
---|
962 | iWaveDev++;
|
---|
963 | if(iWaveDev==1000)
|
---|
964 | iWaveDev=1;
|
---|
965 | iWavePriv=iWaveDev;
|
---|
966 | cwReleaseMutex(hmtxFileName);
|
---|
967 |
|
---|
968 | #ifdef RANDOM_DEBUG
|
---|
969 | // HlpWriteToTrapLog("%s mfData: %x\n", __FUNCTION__, mfData);
|
---|
970 | HlpWriteToTrapLog("%s random array: %x\n", __FUNCTION__, mfData->pRandomArray);
|
---|
971 | #endif
|
---|
972 | if(!mfData->pRandomArray) {
|
---|
973 | /* Not yet playing */
|
---|
974 | CNRINFO cnrInfo;
|
---|
975 | ULONG ulError;
|
---|
976 |
|
---|
977 | #ifdef RANDOM_DEBUG
|
---|
978 | HlpWriteToTrapLog("%s line: %d - No random Array yet\n", __FUNCTION__, __LINE__);
|
---|
979 | #endif
|
---|
980 |
|
---|
981 | WinSendMsg(hwndContainer,CM_QUERYCNRINFO, MPFROMP(&cnrInfo),
|
---|
982 | MPFROMLONG(sizeof(cnrInfo)));
|
---|
983 | /* No objects?? */
|
---|
984 | if(cnrInfo.cRecords==0)
|
---|
985 | return 0;
|
---|
986 | if((mfData->pRandomArray=wpAllocMem(MAX_RANDOM_OBJECTS , &ulError))==NULLHANDLE)
|
---|
987 | return 0;
|
---|
988 |
|
---|
989 | #ifdef RANDOM_DEBUG
|
---|
990 | HlpWriteToTrapLog("%s: alloced random array\n", __FUNCTION__);
|
---|
991 | #endif
|
---|
992 |
|
---|
993 | memset(mfData->pRandomArray, 0, MAX_RANDOM_OBJECTS);
|
---|
994 |
|
---|
995 | #ifdef RANDOM_DEBUG
|
---|
996 | HlpWriteToTrapLog("%s: set array to 0\n", __FUNCTION__);
|
---|
997 | #endif
|
---|
998 |
|
---|
999 | mfData->iNumToPlay=cnrInfo.cRecords; /* # tracks to be played */
|
---|
1000 | mfData->iNumPlayed=0;
|
---|
1001 | if(mfData->iNumToPlay>MAX_RANDOM_OBJECTS)
|
---|
1002 | mfData->iNumToPlay=MAX_RANDOM_OBJECTS;
|
---|
1003 | }
|
---|
1004 |
|
---|
1005 | #ifdef RANDOM_DEBUG
|
---|
1006 | HlpWriteToTrapLog("%s: Now searchin audio file...\n", __FUNCTION__);
|
---|
1007 | #endif
|
---|
1008 |
|
---|
1009 | /* Find an audio file */
|
---|
1010 | notFound=TRUE;
|
---|
1011 | while(notFound){
|
---|
1012 | /* Find track to play */
|
---|
1013 | if((iTrack=_getRandomTrack(mfData))==-1) {
|
---|
1014 | #ifdef RANDOM_DEBUG
|
---|
1015 | HlpWriteToTrapLog("%s: _getRandomTrack returned an error! Quitting.\n", __FUNCTION__);
|
---|
1016 | #endif
|
---|
1017 | cwStopAudioFile(hwndFrame);
|
---|
1018 | return 0;
|
---|
1019 | }
|
---|
1020 |
|
---|
1021 | #ifdef RANDOM_DEBUG
|
---|
1022 | HlpWriteToTrapLog("%s: _getRandomTrack returned: %d.\n", __FUNCTION__, iTrack);
|
---|
1023 | #endif
|
---|
1024 |
|
---|
1025 | for(a=0,mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD,NULL,
|
---|
1026 | MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
|
---|
1027 | a<iTrack && mrc && (int)mrc!=-1;
|
---|
1028 | a++)
|
---|
1029 | {
|
---|
1030 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD, mrc,
|
---|
1031 | MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
|
---|
1032 | #ifdef RANDOM_DEBUG
|
---|
1033 | HlpWriteToTrapLog("a: %d, %x\n", a, mrc);
|
---|
1034 | #endif
|
---|
1035 | };
|
---|
1036 |
|
---|
1037 | #ifdef RANDOM_DEBUG
|
---|
1038 | HlpWriteToTrapLog(" a: %d, %x\n", a, mrc);
|
---|
1039 | #endif
|
---|
1040 |
|
---|
1041 | if(!mrc)
|
---|
1042 | {
|
---|
1043 | #ifdef RANDOM_DEBUG
|
---|
1044 | HlpWriteToTrapLog("%s: No mrc. Quitting.\n", __FUNCTION__);
|
---|
1045 | #endif
|
---|
1046 | cwStopAudioFile(hwndFrame);/* Clean up */
|
---|
1047 | return 0;
|
---|
1048 | }
|
---|
1049 |
|
---|
1050 | contentObject=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object
|
---|
1051 | if((contentObject=cwGetFileSystemObject(contentObject))==NULLHANDLE)
|
---|
1052 | continue;
|
---|
1053 |
|
---|
1054 | /* Check if it's an audio file thus playable */
|
---|
1055 | if(contentObject->somIsA(cwAudioClass) ||
|
---|
1056 | /* contentObject->somIsA(mmAudioClass) ||*/
|
---|
1057 | contentObject->somIsA(mmMIDIClass)) {
|
---|
1058 | notFound=FALSE;
|
---|
1059 | ulNameSize=sizeof(name);
|
---|
1060 | ((WPFileSystem*)contentObject)->wpQueryRealName(name,&ulNameSize,TRUE);
|
---|
1061 | }
|
---|
1062 | };/* while */
|
---|
1063 |
|
---|
1064 | #ifdef RANDOM_DEBUG
|
---|
1065 | HlpWriteToTrapLog("%s: Got an object. Trying to start it...\n", __FUNCTION__);
|
---|
1066 | #endif
|
---|
1067 |
|
---|
1068 | /* Now start it */
|
---|
1069 | PBYTE pByte=mfData->pRandomArray;
|
---|
1070 | /* Prevent stop method from deleting our vars */
|
---|
1071 | mfData->pRandomArray=NULLHANDLE;
|
---|
1072 |
|
---|
1073 | cwStopAudioFile(hwndFrame);/* Reset playing vars and remove in use emphasis */
|
---|
1074 |
|
---|
1075 | if(!getMessage(chrCommand, IDSTR_STARTINGTRACK, sizeof(chrCommand), queryResModuleHandle(), hwndFrame))
|
---|
1076 | sprintf(chrCommand, "Starting track...");
|
---|
1077 | setPlayTimeText2(this, chrCommand);
|
---|
1078 |
|
---|
1079 | mfData->pRandomArray=pByte;
|
---|
1080 |
|
---|
1081 | if(contentObject->somIsA(mmMIDIClass))
|
---|
1082 | strncpy(chrDevice,"SEQUENCER", sizeof(chrDevice) - 1);
|
---|
1083 | else /*if(contentObject->somIsA(cwAudioClass) || contentObject->somIsA(mmAudioClass))*/
|
---|
1084 | strncpy(chrDevice,"WAVEAUDIO", sizeof(chrDevice));
|
---|
1085 |
|
---|
1086 | chrDevice[sizeof(chrDevice)-1]=0;
|
---|
1087 |
|
---|
1088 | hwndNotify=playControlDialogFromFrameHWND(hwndFrame);//WinWindowFromID(hwndTop, IDDLG_TOPMIDDLE);
|
---|
1089 |
|
---|
1090 | /* Start audio file */
|
---|
1091 | sprintf(chrCommand,"open \"%s\" type %s alias wave%d SHAREABLE wait",name, chrDevice, iWavePriv);
|
---|
1092 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), hwndNotify, 0);
|
---|
1093 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS)
|
---|
1094 | return 0;
|
---|
1095 | /* Set time format */
|
---|
1096 | sprintf(chrCommand,"SET wave%d TIME FORMAT MILLISECONDS wait", iWavePriv);
|
---|
1097 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
1098 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
1099 | sprintf(chrCommand,"close wave%d wait",iWavePriv);
|
---|
1100 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
1101 | return 0;
|
---|
1102 | }
|
---|
1103 |
|
---|
1104 | sprintf(chrCommand,"SETPOSITIONADVISE wave%d ON EVERY 1000 notify", iWavePriv);
|
---|
1105 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg),hwndNotify, 0);
|
---|
1106 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
1107 | sprintf(chrCommand,"close wave%d wait",iWavePriv);
|
---|
1108 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
1109 | return 0;
|
---|
1110 | }
|
---|
1111 |
|
---|
1112 | /* Get wave length in ms */
|
---|
1113 | sprintf(chrCommand,"STATUS wave%d LENGTH WAIT", iWavePriv);
|
---|
1114 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
1115 | if((rc & 0x0000ffff)==MCIERR_SUCCESS) {
|
---|
1116 | iTime2=atoi(retMsg);
|
---|
1117 | sprintf(chrCommand,"%d:%02d %d:%02d -%d:%02d",iTime2/1000/60,(iTime2/1000)%60,
|
---|
1118 | 0, 0,
|
---|
1119 | iTime2/1000/60,(iTime2/1000)%60);
|
---|
1120 | // WinSetWindowText(WinWindowFromID(hwndTop, IDST_PLAYTIME), chrCommand);
|
---|
1121 | // WinSetWindowText(WinWindowFromID(playControlDialogFromFrameHWND(hwndFrame), IDST_PLAYTIME), chrCommand);
|
---|
1122 | // WinSetWindowText(playTimeControlFromFrameHWND(hwndFrame), chrCommand);
|
---|
1123 | }
|
---|
1124 | ulTotalLength=iTime2;
|
---|
1125 |
|
---|
1126 | /* Set volume */
|
---|
1127 | sprintf(chrCommand,"SET wave%d AUDIO VOLUME %d wait", iWavePriv, ulVolume);
|
---|
1128 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
1129 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
1130 | sprintf(chrCommand,"close wave%d",iWavePriv);
|
---|
1131 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
1132 | return 0;
|
---|
1133 | }
|
---|
1134 |
|
---|
1135 | sprintf(chrCommand,"play wave%d FROM 0", iWavePriv);
|
---|
1136 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
1137 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
1138 | sprintf(chrCommand,"close wave%d",iWavePriv);
|
---|
1139 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
1140 | return 0;
|
---|
1141 | }
|
---|
1142 | /* Start pos timer. SET MCIPOSITIONADVICE fails when seeking in the wave.
|
---|
1143 | Don't know why. */
|
---|
1144 | // WinStartTimer(WinQueryAnchorBlock(hwndFrame), WinWindowFromID(hwndTop, IDDLG_TOPMIDDLE), IDTIMER_PLAY, PLAYTIMER_DELAY);
|
---|
1145 | WinStartTimer(WinQueryAnchorBlock(hwndFrame), playControlDialogFromFrameHWND(hwndFrame), IDTIMER_PLAY, PLAYTIMER_DELAY);
|
---|
1146 |
|
---|
1147 | /* Set emphasis by adding the object to the inuse list */
|
---|
1148 | memset(&myViewItem, 0,sizeof(myViewItem));
|
---|
1149 | myViewItem.useItem.type=USAGE_OPENVIEW;
|
---|
1150 | myViewItem.viewItem.view=OPEN_PLAYING;
|
---|
1151 |
|
---|
1152 | WPObject* wpObject=contentObject;
|
---|
1153 |
|
---|
1154 | if(wpObject->wpAddToObjUseList(&myViewItem.useItem))
|
---|
1155 | {
|
---|
1156 | myViewItem.bIsInUseList=TRUE;
|
---|
1157 | };
|
---|
1158 | /* Select the object */
|
---|
1159 | WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(mrc),
|
---|
1160 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
1161 |
|
---|
1162 | iWave=iWavePriv;
|
---|
1163 | currentObject=wpObject;
|
---|
1164 | mrcPlaying=mrc;
|
---|
1165 | /* The start position of the play command */
|
---|
1166 | ulStartPosition=0;
|
---|
1167 | ulPos=0;
|
---|
1168 | bPaused=FALSE;
|
---|
1169 | mfData->iNumPlayed++;
|
---|
1170 |
|
---|
1171 | return 0;
|
---|
1172 | }
|
---|
1173 |
|
---|
1174 | BOOL CWMediaFolder::cwStopAudioFile(HWND hwndFrame)
|
---|
1175 | {
|
---|
1176 | char chrCommand[50];
|
---|
1177 | char retMsg[100];
|
---|
1178 | ULONG rc;
|
---|
1179 | HWND hwndContainer=WinWindowFromID(hwndFrame, FID_CLIENT);
|
---|
1180 |
|
---|
1181 | TRY_LOUD(MEDIAFLDR_STOP_AUDIO) {
|
---|
1182 | if(iWave) {
|
---|
1183 | if(mfData->pRandomArray) {
|
---|
1184 | wpFreeMem(mfData->pRandomArray);
|
---|
1185 | mfData->pRandomArray=NULLHANDLE;
|
---|
1186 | mfData->iNumToPlay=0; /* # tracks to be played */
|
---|
1187 | mfData->iNumPlayed=0;
|
---|
1188 | }
|
---|
1189 |
|
---|
1190 | sprintf(chrCommand,"stop wave%d wait", iWave);
|
---|
1191 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
1192 |
|
---|
1193 | sprintf(chrCommand,"close wave%d wait", iWave);
|
---|
1194 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
1195 |
|
---|
1196 | _resetDisplay(this);
|
---|
1197 | //_resetDisplay(topControlFromFrameHWND(hwndFrame));
|
---|
1198 | // WinStopTimer(WinQueryAnchorBlock(hwndFrame), WinWindowFromID(hwndTop, IDDLG_TOPMIDDLE), IDTIMER_PLAY);
|
---|
1199 | WinStopTimer(WinQueryAnchorBlock(hwndFrame), playControlDialogFromFrameHWND(hwndFrame), IDTIMER_PLAY);
|
---|
1200 |
|
---|
1201 | /* Remove from inuse list */
|
---|
1202 | if(myViewItem.bIsInUseList && somIsObj(currentObject))
|
---|
1203 | {
|
---|
1204 | WPObject *wpObject=cwGetFileSystemObject(currentObject);
|
---|
1205 | if(somIsObj(wpObject))
|
---|
1206 | if(wpObject->wpDeleteFromObjUseList(&myViewItem.useItem))
|
---|
1207 | myViewItem.bIsInUseList=FALSE;
|
---|
1208 | };
|
---|
1209 |
|
---|
1210 | //HlpWriteToTrapLog("\n1 line %d.\n");
|
---|
1211 |
|
---|
1212 | /* Deselect the object */
|
---|
1213 | if(WinIsWindow(WinQueryAnchorBlock(hwndFrame), hwndContainer))
|
---|
1214 | WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(mrcPlaying),
|
---|
1215 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1216 |
|
---|
1217 | iWave=0;
|
---|
1218 | currentObject=NULLHANDLE;
|
---|
1219 | mrcPlaying=NULLHANDLE;
|
---|
1220 | ulPos=0;
|
---|
1221 | }
|
---|
1222 | else
|
---|
1223 | {
|
---|
1224 | PMINIRECORDCORE mrc;
|
---|
1225 | WPObject * contentObject;
|
---|
1226 |
|
---|
1227 | if(mmGetOtherPlayingAudioFile( this, hwndContainer, &contentObject, &mrc)) {
|
---|
1228 | ((MMAudio*)contentObject)->wpViewObject( NULLHANDLE,0xbbf9, NULLHANDLE);
|
---|
1229 | #if 0
|
---|
1230 | iWave=0;
|
---|
1231 | currentObject=NULLHANDLE;
|
---|
1232 | mrcPlaying=NULLHANDLE;
|
---|
1233 | ulPos=0;
|
---|
1234 | #endif
|
---|
1235 | WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(mrc),
|
---|
1236 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1237 | }
|
---|
1238 | #if 0
|
---|
1239 | PMINIRECORDCORE mrc;
|
---|
1240 | WPObject * contentObject;
|
---|
1241 |
|
---|
1242 | /* See if we have an audio file played with doubleclick */
|
---|
1243 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORDEMPHASIS,MPFROMLONG(CMA_FIRST),
|
---|
1244 | MPFROMSHORT(CRA_INUSE));
|
---|
1245 | if(mrc) {
|
---|
1246 | SOMClass *cwAudioClass=cwGetSomClass("MMAudio");
|
---|
1247 | contentObject=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object
|
---|
1248 | if(somIsObj(contentObject) && somIsObj(cwAudioClass)) {
|
---|
1249 | if((contentObject=cwGetFileSystemObject(contentObject))!=NULLHANDLE) {
|
---|
1250 | /* Check if it's an audio file thus playable */
|
---|
1251 | if(contentObject->somIsA(cwAudioClass)) {
|
---|
1252 | if(((MMAudio*)contentObject)->wpQueryDefaultView()==0xbbf9){
|
---|
1253 | /* If stop menu is default, this means the track is playing. */
|
---|
1254 | ((MMAudio*)contentObject)->wpViewObject( NULLHANDLE,0xbbf9, NULLHANDLE);
|
---|
1255 | iWave=0;
|
---|
1256 | currentObject=NULLHANDLE;
|
---|
1257 | mrcPlaying=NULLHANDLE;
|
---|
1258 | ulPos=0;
|
---|
1259 | WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(mrc),
|
---|
1260 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
1261 |
|
---|
1262 | };
|
---|
1263 | }
|
---|
1264 | }
|
---|
1265 | }/* somIsObj() */
|
---|
1266 | }
|
---|
1267 | #endif
|
---|
1268 | }
|
---|
1269 | }/* Try */
|
---|
1270 | CATCH(MEDIAFLDR_STOP_AUDIO)
|
---|
1271 | {
|
---|
1272 | SysWriteToTrapLog("\nTrap occured in %s, file: %s, near line %d.\n",
|
---|
1273 | __FUNCTION__, __FILE__, __LINE__);
|
---|
1274 | } END_CATCH;
|
---|
1275 |
|
---|
1276 | return TRUE;
|
---|
1277 | }
|
---|
1278 |
|
---|
1279 | BOOL CWMediaFolder::cwPauseAudioFile(HWND hwndFrame)
|
---|
1280 | {
|
---|
1281 | char chrCommand[50];
|
---|
1282 | char retMsg[100];
|
---|
1283 | ULONG rc;
|
---|
1284 |
|
---|
1285 | if(!bPaused) {
|
---|
1286 | sprintf(chrCommand,"PAUSE wave%d wait", iWave);
|
---|
1287 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
1288 | bPaused=TRUE;
|
---|
1289 | }else
|
---|
1290 | {
|
---|
1291 | sprintf(chrCommand,"RESUME wave%d wait", iWave);
|
---|
1292 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
1293 | bPaused=FALSE;
|
---|
1294 | showPlayTimeDisplay(this, TRUE);
|
---|
1295 | }
|
---|
1296 |
|
---|
1297 | return TRUE;
|
---|
1298 | }
|
---|
1299 |
|
---|
1300 | BOOL CWMediaFolder::cwSeekAudioFile(LONG lPosSec)
|
---|
1301 | {
|
---|
1302 | char chrCommand[50];
|
---|
1303 | char retMsg[20];
|
---|
1304 | APIRET rc;
|
---|
1305 |
|
---|
1306 | sprintf(chrCommand,"PLAY wave%d from %d", iWave, lPosSec);
|
---|
1307 | rc=mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
1308 | ulStartPosition=lPosSec;
|
---|
1309 | bPaused=FALSE;
|
---|
1310 |
|
---|
1311 | return TRUE;
|
---|
1312 | }
|
---|
1313 |
|
---|
1314 | void CWMediaFolder::cwPlayTimeCallback(HWND hwndFrame, LONG lPosSec)
|
---|
1315 | {
|
---|
1316 | char chrCommand[50];
|
---|
1317 | char retMsg[20];
|
---|
1318 | ULONG rc;
|
---|
1319 |
|
---|
1320 | /* Timeout. Check if wave is still playing */
|
---|
1321 | sprintf(chrCommand,"STATUS wave%d MODE WAIT", iWave);
|
---|
1322 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
1323 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
1324 | /* Problem with MCI. Clean up. The Timer will be stopped in the method */
|
---|
1325 | cwStopAudioFile(hwndFrame);
|
---|
1326 | }
|
---|
1327 | else {
|
---|
1328 | if(!stricmp(retMsg, "stopped")) {
|
---|
1329 | /* Audio file played. Start next */
|
---|
1330 | cwPlayAudioFile(hwndFrame, PLAY_NEXT);
|
---|
1331 | }
|
---|
1332 | showPlayTimeDisplay(this, TRUE);/* Ensure display is visible */
|
---|
1333 | }
|
---|
1334 | }
|
---|
1335 |
|
---|
1336 |
|
---|