1 | /*
|
---|
2 | * This file is (C) Chris Wohlgemuth 2002-2003
|
---|
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 | #include <stdio.h>
|
---|
24 | #include <stdlib.h>
|
---|
25 | #include <ctype.h>
|
---|
26 | #include "cdfolder.hh"
|
---|
27 | #include "mediafolderres.h"
|
---|
28 | #include "cwcdtrack.hh"
|
---|
29 |
|
---|
30 | #include "sys_funcs.h"
|
---|
31 |
|
---|
32 | extern HMTX hmtxFileName;
|
---|
33 | extern int iWaveDev;
|
---|
34 | PFNWP pfnwpGenericCDFrame;
|
---|
35 |
|
---|
36 | /* For calling the method in the MMAudio class. Linking to the DLL would require the
|
---|
37 | new audio classes. By dynamically querying the method the media folder works without
|
---|
38 | installing the audio classes. */
|
---|
39 | typedef ULONG SOMLINK somTP_MMCDTrack_cwmmQueryTrackInfo(MMCDTrack *somSelf,
|
---|
40 | char** chrString,
|
---|
41 | ULONG ulSize,
|
---|
42 | int iWhich);
|
---|
43 | typedef somTP_MMCDTrack_cwmmQueryTrackInfo *somTD_MMCDTrack_cwmmQueryTrackInfo;
|
---|
44 | extern somTD_MMCDTrack_cwmmQueryTrackInfo methodPtrCDTrack;
|
---|
45 |
|
---|
46 | BOOL extern CDQueryCDDrives(int *iNumCD, char * cFirstDrive);
|
---|
47 |
|
---|
48 | BOOL getMessage(char* text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd);
|
---|
49 | HMODULE queryResModuleHandle(void);
|
---|
50 |
|
---|
51 | ULONG cwRequestMutex(HMTX hmtxBMP, ULONG ulTimeOut);
|
---|
52 | ULONG cwReleaseMutex(HMTX hmtxBMP);
|
---|
53 |
|
---|
54 | SOMClass* somhlpGetSomClass(char* chrClassName);
|
---|
55 | extern BOOL somhlpQueryCWCDTrackMethodPtr(CWMediaFolder *thisPtr);
|
---|
56 | MRESULT EXPENTRY cdFrameProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
---|
57 | extern void showPlayTimeDisplay(CWMediaFolder *thisPtr, BOOL bShow);
|
---|
58 | void setPlayTimeText2(CWMediaFolder *thisPtr, char * theText);
|
---|
59 | void HlpWriteToTrapLog(const char* chrFormat, ...);
|
---|
60 | /* Get the HWND of the play control dialog. This Dialog is on top of
|
---|
61 | the top frame control. */
|
---|
62 | HWND playControlDialogFromFrameHWND(HWND hwndFrame);
|
---|
63 |
|
---|
64 |
|
---|
65 | BOOL CWCDFolder::wpSetupOnce(PSZ pSetupString)
|
---|
66 | {
|
---|
67 | /**************************************************
|
---|
68 | * *
|
---|
69 | * *
|
---|
70 | **************************************************/
|
---|
71 | BOOL rcParent=FALSE;
|
---|
72 | char buffer[CCHMAXPATH];
|
---|
73 | ULONG bufferSize;
|
---|
74 | int iIndex;
|
---|
75 |
|
---|
76 | rcParent=CWMediaFolder::wpSetupOnce(pSetupString);
|
---|
77 |
|
---|
78 | /* Doing our own setup here if not done by the user. */
|
---|
79 | #if 0
|
---|
80 | /* This is already done in the media folder class */
|
---|
81 | bufferSize=sizeof(buffer);
|
---|
82 | if(!wpScanSetupString(pSetupString,"DEFAULTVIEW",buffer,&bufferSize))
|
---|
83 | wpSetup( "DEFAULTVIEW=DETAILS");/* Fill in defaults */
|
---|
84 |
|
---|
85 | bufferSize=sizeof(buffer);
|
---|
86 | if(!wpScanSetupString(pSetupString,"ICONVIEW",buffer,&bufferSize))
|
---|
87 | wpSetup( "ICONVIEW=NONFLOWED,MINI");/* Fill in defaults */
|
---|
88 |
|
---|
89 | /* Size and position of the folder window */
|
---|
90 | bufferSize=sizeof(buffer);
|
---|
91 | if(!wpScanSetupString(pSetupString,"ICONVIEWPOS",buffer,&bufferSize))
|
---|
92 | wpSetup( "ICONVIEWPOS=20,10,60,75");/* Fill in defaults */
|
---|
93 | #endif
|
---|
94 |
|
---|
95 | /* Set folder details- and sortclass to CWAudioShadow so track infos are shown */
|
---|
96 | bufferSize=sizeof(buffer);
|
---|
97 | if(!wpScanSetupString(pSetupString,"DETAILSCLASS",buffer,&bufferSize))
|
---|
98 | wpSetup("DETAILSCLASS=MMAudio");/* Fill in defaults */
|
---|
99 |
|
---|
100 | bufferSize=sizeof(buffer);
|
---|
101 | if(!wpScanSetupString(pSetupString,"SORTCLASS",buffer,&bufferSize))
|
---|
102 | wpSetup("SORTCLASS=MMCDTrack");/* Fill in defaults */
|
---|
103 |
|
---|
104 | /* This works only on Warp 4 and above */
|
---|
105 | bufferSize=sizeof(buffer);
|
---|
106 | if(!wpScanSetupString(pSetupString,"DETAILSTODISPLAY",buffer,&bufferSize))
|
---|
107 | /* This works only on Warp 4 and above */
|
---|
108 | wpSetup("DETAILSTODISPLAY=0,1,12,16,17,18");/* Fill in defaults */
|
---|
109 |
|
---|
110 | /* This works only on Warp 4 and above */
|
---|
111 | bufferSize=sizeof(buffer);
|
---|
112 | if(!wpScanSetupString(pSetupString,"SORTBYATTR",buffer,&bufferSize))
|
---|
113 | /* This works only on Warp 4 and above */
|
---|
114 | wpSetup("SORTBYATTR=6,24,28,29,30");/* Fill in defaults */
|
---|
115 |
|
---|
116 | return rcParent;
|
---|
117 | }
|
---|
118 |
|
---|
119 | BOOL CWCDFolder::wpSetup(PSZ pSetupString)
|
---|
120 | {
|
---|
121 | /**************************************************
|
---|
122 | * *
|
---|
123 | * *
|
---|
124 | **************************************************/
|
---|
125 | char buffer[3];
|
---|
126 | ULONG bufferSize;
|
---|
127 |
|
---|
128 | /* Set drive letter */
|
---|
129 | bufferSize=sizeof(buffer);
|
---|
130 | if(wpScanSetupString(pSetupString, CDFLDR_DRIVE, buffer,&bufferSize))
|
---|
131 | {
|
---|
132 | if(buffer[1]==':' /*&& (buffer[0]>='A' && buffer[0]<='Z' )*/) {
|
---|
133 | buffer[2]=0;
|
---|
134 | strcpy(chrDrive, buffer);
|
---|
135 | }
|
---|
136 | }
|
---|
137 | return CWMediaFolder::wpSetup(pSetupString);
|
---|
138 | }
|
---|
139 |
|
---|
140 | BOOL CWCDFolder::wpSaveState()
|
---|
141 | {
|
---|
142 |
|
---|
143 | wpSaveString("CWCDFolder", KEY_DRIVE, (PBYTE)&chrDrive);
|
---|
144 |
|
---|
145 | return CWMediaFolder::wpSaveState();
|
---|
146 | }
|
---|
147 |
|
---|
148 | BOOL CWCDFolder::wpRestoreState(ULONG ulReserved)
|
---|
149 | {
|
---|
150 | ULONG dataSize;
|
---|
151 |
|
---|
152 | chrDrive[0]=0;
|
---|
153 | dataSize=sizeof(chrDrive);
|
---|
154 | if(wpRestoreString("CWCDFolder",KEY_DRIVE,(PBYTE)&chrDrive,&dataSize))
|
---|
155 | chrDrive[2]=0;
|
---|
156 |
|
---|
157 | return CWMediaFolder::wpRestoreState(ulReserved);
|
---|
158 | }
|
---|
159 |
|
---|
160 | ULONG CWCDFolder::wpFilterPopupMenu(ULONG ulFlags, HWND hwndCnr, BOOL fMultiSelect)
|
---|
161 | {
|
---|
162 | return CWMediaFolder::wpFilterPopupMenu(ulFlags, hwndCnr, fMultiSelect)&
|
---|
163 | ~(CTXT_SORT|CTXT_ARRANGE|CTXT_COPY|CTXT_ICON|CTXT_CHANGETOICON|CTXT_CHANGETOTREE|CTXT_CHANGETODETAILS);
|
---|
164 | }
|
---|
165 |
|
---|
166 | ULONG CWCDFolder::wpAddObjectGeneralPage2(HWND hwndNotebook)
|
---|
167 | {
|
---|
168 | return SETTINGS_PAGE_REMOVED;
|
---|
169 | }
|
---|
170 |
|
---|
171 | ULONG CWCDFolder::wpAddFolderSortPage(HWND hwndNotebook)
|
---|
172 | {
|
---|
173 | return SETTINGS_PAGE_REMOVED;
|
---|
174 | }
|
---|
175 |
|
---|
176 | ULONG CWCDFolder::wpAddFolderIncludePage(HWND hwndNotebook)
|
---|
177 | {
|
---|
178 | return SETTINGS_PAGE_REMOVED;
|
---|
179 | }
|
---|
180 |
|
---|
181 | ULONG CWCDFolder::wpQueryConcurrentView()
|
---|
182 | {
|
---|
183 | /* Only one view allowed */
|
---|
184 | return 2;//CCVIEW_OFF
|
---|
185 | }
|
---|
186 |
|
---|
187 | MRESULT CWCDFolder::wpDragOver(HWND hwndCnr,PDRAGINFO pDragInfo)
|
---|
188 | {
|
---|
189 | return MRFROM2SHORT( DOR_NEVERDROP, DO_MOVE);/* Dropping is not allowed */
|
---|
190 | }
|
---|
191 |
|
---|
192 | BOOL CWCDFolder::wpRefresh(ULONG ulView, PVOID pReserved)
|
---|
193 | {
|
---|
194 | // SysWriteToTrapLog("%s: view: %d, %x, %x\n",
|
---|
195 | // __FUNCTION__, ulView, ulView, cwQueryMFldrFlags() );
|
---|
196 |
|
---|
197 | /* User changes the view of the CD-Folder, don't reinsert the tracks when changing from/to
|
---|
198 | compact view. */
|
---|
199 | if(ulView==OPEN_DETAILS && !(cwQueryMFldrFlags() & MFLDR_VIEW_COMPACT))
|
---|
200 | cwInsertAllTracks(chrDrive);
|
---|
201 | /* Normal refresh */
|
---|
202 | if(ulView==0)
|
---|
203 | cwInsertAllTracks(chrDrive);
|
---|
204 | return CWMediaFolder::wpRefresh(ulView, pReserved);
|
---|
205 | }
|
---|
206 |
|
---|
207 |
|
---|
208 | HWND CWCDFolder::wpOpen(HWND hwndCnr,ULONG ulView,ULONG ulParam)
|
---|
209 | {
|
---|
210 |
|
---|
211 | if(ulView==OPEN_CONTENTS||ulView==OPEN_TREE||ulView==OPEN_DETAILS||ulView==OPEN_DEFAULT /*|| ulView==OPEN_MMDISK*/) {
|
---|
212 | /* OPEN_MMDISK is a private view to indicate the folder was opened from the CD drive */
|
---|
213 | cwInsertAllTracks(chrDrive);
|
---|
214 | hwndFrameCDFldr=CWMediaFolder::wpOpen(hwndCnr, ulView, ulParam);
|
---|
215 |
|
---|
216 | if(hwndFrameCDFldr) {
|
---|
217 | /* We have the folder window */
|
---|
218 | char chrTemp[50];
|
---|
219 | HOBJECT hObject;
|
---|
220 |
|
---|
221 | /* Add view to drives inuse list */
|
---|
222 | sprintf(chrTemp,"<WP_DRIVE_%c>",chrDrive[0]);
|
---|
223 | if((hObject=WinQueryObject(chrTemp))!=NULLHANDLE) {
|
---|
224 | WPObject *wpObject;
|
---|
225 |
|
---|
226 | wpObject=((M_WPObject*)__ClassObject)->wpclsQueryObject( hObject);
|
---|
227 | if(somIsObj(wpObject)) {
|
---|
228 | diskUseItem.wpDiskObj=wpObject;
|
---|
229 | diskUseItem.useItem.type=USAGE_OPENVIEW;
|
---|
230 | memset(&diskUseItem.viewItem, 0, sizeof(VIEWITEM));
|
---|
231 | diskUseItem.viewItem.handle=hwndFrameCDFldr;
|
---|
232 | diskUseItem.viewItem.view=OPEN_DEFAULT;
|
---|
233 | wpObject->wpAddToObjUseList(&diskUseItem.useItem);
|
---|
234 | }/* somIsObj() */
|
---|
235 | }
|
---|
236 |
|
---|
237 | /* Remove random checkbox for now... */
|
---|
238 | WinShowWindow( WinWindowFromID(playControlDialogFromFrameHWND(hwndFrameCDFldr), IDCB_RANDOM)
|
---|
239 | , FALSE);
|
---|
240 | /* Subclass frame to remove items from menubar */
|
---|
241 | pfnwpCDFrame=WinSubclassWindow(hwndFrameCDFldr, cdFrameProc);
|
---|
242 | pfnwpGenericCDFrame=pfnwpFrame;
|
---|
243 | }/* if(hwnd) */
|
---|
244 | return hwndFrameCDFldr;
|
---|
245 | }
|
---|
246 | return CWMediaFolder::wpOpen(hwndCnr, ulView, ulParam);
|
---|
247 | }
|
---|
248 |
|
---|
249 | BOOL CWCDFolder::cwClose(HWND hwndFrame)
|
---|
250 | {
|
---|
251 | BOOL bRC;
|
---|
252 |
|
---|
253 | bRC=CWMediaFolder::cwClose(hwndFrame);
|
---|
254 |
|
---|
255 | if(bRC) {
|
---|
256 | /* User confirmed close */
|
---|
257 | if(somIsObj(diskUseItem.wpDiskObj)) {
|
---|
258 | diskUseItem.wpDiskObj->wpDeleteFromObjUseList(&diskUseItem.useItem);
|
---|
259 | /* The disk object is locked because of wpclQueryObject in wpOpen() */
|
---|
260 | diskUseItem.wpDiskObj->wpUnlockObject();
|
---|
261 | hwndFrameCDFldr=NULLHANDLE;
|
---|
262 | }
|
---|
263 | }
|
---|
264 | return bRC;
|
---|
265 | }
|
---|
266 |
|
---|
267 | ULONG CWCDFolder::cwPlayAudioFile(HWND hwndFrame, ULONG ulWhich)
|
---|
268 | {
|
---|
269 | HWND hwndContainer;
|
---|
270 | PMINIRECORDCORE mrc, mrcTemp;
|
---|
271 | WPObject * contentObject;
|
---|
272 | WPObject * tempObject;
|
---|
273 | SOMClass *mmCDTrackClass;
|
---|
274 | char chrCommand[CCHMAXPATH*2];
|
---|
275 | char chrDevice[30];
|
---|
276 | char retMsg[20];
|
---|
277 | ULONG rc;
|
---|
278 | int iWavePriv;
|
---|
279 | int iTime2;
|
---|
280 | int iPrevTrack=0;
|
---|
281 |
|
---|
282 |
|
---|
283 | hwndContainer=WinWindowFromID(hwndFrame, FID_CLIENT);
|
---|
284 | if(!WinIsWindow(WinQueryAnchorBlock(hwndFrame), hwndContainer))
|
---|
285 | return 0;
|
---|
286 |
|
---|
287 | /* Get class object */
|
---|
288 | mmCDTrackClass=somhlpGetSomClass("MMCDTrack");
|
---|
289 | if(!mmCDTrackClass)
|
---|
290 | return 0;
|
---|
291 |
|
---|
292 | /* Get new ID for wave device */
|
---|
293 | if(cwRequestMutex(hmtxFileName, 100000)==ERROR_TIMEOUT)
|
---|
294 | return FALSE;
|
---|
295 | iWaveDev++;
|
---|
296 | if(iWaveDev==1000)
|
---|
297 | iWaveDev=1;
|
---|
298 | iWavePriv=iWaveDev;
|
---|
299 | cwReleaseMutex(hmtxFileName);
|
---|
300 |
|
---|
301 | BOOL notFound;
|
---|
302 |
|
---|
303 | switch(ulWhich) {
|
---|
304 | case PLAY_FIRST:
|
---|
305 | {
|
---|
306 |
|
---|
307 | /* Get first selected container item of our folder */
|
---|
308 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORDEMPHASIS, MPFROMSHORT(CMA_FIRST),
|
---|
309 | MPFROMSHORT(CRA_SELECTED));
|
---|
310 |
|
---|
311 | if(iWave!=0 && mrc && (int)mrc!=-1) {
|
---|
312 |
|
---|
313 | cwStopAudioFile(hwndFrame);
|
---|
314 | return cwPlayAudioFile(hwndFrame, PLAY_FIRST);
|
---|
315 | }
|
---|
316 | if(!mrc || (int)mrc==-1)
|
---|
317 | /* Get first container item of our folder */
|
---|
318 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD,NULL,
|
---|
319 | MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER));
|
---|
320 |
|
---|
321 | if(!mrc || (int)mrc==-1)
|
---|
322 | return 0;
|
---|
323 |
|
---|
324 | notFound=TRUE;
|
---|
325 | do {
|
---|
326 | contentObject=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object
|
---|
327 | if(somIsObj(contentObject)) {
|
---|
328 | /* Get file system object or NULL */
|
---|
329 | if((contentObject=cwGetFileSystemObject(contentObject))==NULLHANDLE)
|
---|
330 | continue;
|
---|
331 | tempObject=contentObject;
|
---|
332 | }
|
---|
333 | else
|
---|
334 | return 0;/* Error */
|
---|
335 |
|
---|
336 | if(contentObject->somIsA(mmCDTrackClass))
|
---|
337 | notFound=FALSE;
|
---|
338 | else
|
---|
339 | /* Try next object */
|
---|
340 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD, mrc,
|
---|
341 | MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
|
---|
342 | }while(notFound && mrc);
|
---|
343 | break;
|
---|
344 | }
|
---|
345 | case PLAY_NEXT:
|
---|
346 | if(iWave==0)
|
---|
347 | return cwPlayAudioFile(hwndFrame, PLAY_FIRST);/* Not yet playing */
|
---|
348 |
|
---|
349 | /* We are currently playing */
|
---|
350 | mrcTemp=mrcPlaying;
|
---|
351 |
|
---|
352 | /* Get next container item of our folder */
|
---|
353 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD,mrcTemp,
|
---|
354 | MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
|
---|
355 |
|
---|
356 | if(!mrc || (int)mrc==-1)
|
---|
357 | return 0;
|
---|
358 |
|
---|
359 | notFound=TRUE;
|
---|
360 | while(notFound && mrc && (int)mrc!=-1){
|
---|
361 | contentObject=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object
|
---|
362 | if(somIsObj(contentObject)) {
|
---|
363 | /* Get file system object or NULL */
|
---|
364 | if((contentObject=cwGetFileSystemObject(contentObject))==NULLHANDLE)
|
---|
365 | continue;
|
---|
366 | tempObject=contentObject;
|
---|
367 | }
|
---|
368 | else
|
---|
369 | return 0;/* Error */
|
---|
370 |
|
---|
371 | if(contentObject->somIsA(mmCDTrackClass))
|
---|
372 | notFound=FALSE;
|
---|
373 | else
|
---|
374 | /* Try next object */
|
---|
375 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD, mrc,
|
---|
376 | MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER));
|
---|
377 | };
|
---|
378 |
|
---|
379 | /* Remove from inuse list */
|
---|
380 | if(myViewItem.bIsInUseList)
|
---|
381 | {
|
---|
382 | WPObject *wpObject=cwGetFileSystemObject(currentObject);
|
---|
383 | if(wpObject->wpDeleteFromObjUseList(&myViewItem.useItem))
|
---|
384 | myViewItem.bIsInUseList=FALSE;
|
---|
385 | };
|
---|
386 |
|
---|
387 | /* Deselect the object */
|
---|
388 | if(WinIsWindow(WinQueryAnchorBlock(hwndFrame), hwndContainer))
|
---|
389 | WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(mrcPlaying),
|
---|
390 | MPFROM2SHORT(FALSE, CRA_SELECTED));
|
---|
391 |
|
---|
392 | if(!mrc) {
|
---|
393 | if(ulFlags & FLAG_REPEAT)
|
---|
394 | return cwPlayAudioFile(hwndFrame, PLAY_FIRST);
|
---|
395 | else {
|
---|
396 | cwStopAudioFile(hwndFrame);
|
---|
397 | return 0;
|
---|
398 | }
|
---|
399 | }
|
---|
400 |
|
---|
401 | break;
|
---|
402 | case PLAY_PREV:
|
---|
403 |
|
---|
404 | if(iWave==0)
|
---|
405 | return cwPlayAudioFile(hwndFrame, PLAY_FIRST);/* Not yet playing, so start the first one. */
|
---|
406 |
|
---|
407 | /* We are currently playing */
|
---|
408 | mrcTemp=mrcPlaying;
|
---|
409 | /* Check the current time. If we are at the very beginning of the track skip to the previous track
|
---|
410 | otherwise skip to the beginning of the current track. */
|
---|
411 | if(ulPos<=2) {
|
---|
412 | /* Get previous container item of our folder */
|
---|
413 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD,mrcTemp,
|
---|
414 | MPFROM2SHORT(CMA_PREV,CMA_ITEMORDER));
|
---|
415 | }
|
---|
416 | else
|
---|
417 | mrc=NULLHANDLE;
|
---|
418 |
|
---|
419 | cwStopAudioFile(hwndFrame);
|
---|
420 | if(!mrc)
|
---|
421 | mrc=mrcTemp;
|
---|
422 |
|
---|
423 | /* Find an audio file */
|
---|
424 | notFound=TRUE;
|
---|
425 | while(notFound && mrc && (int)mrc!=-1){
|
---|
426 | contentObject=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object
|
---|
427 | if(somIsObj(contentObject)) {
|
---|
428 | /* Get file system object or NULL */
|
---|
429 | if((contentObject=cwGetFileSystemObject(contentObject))==NULLHANDLE)
|
---|
430 | continue;
|
---|
431 | tempObject=contentObject;
|
---|
432 | }
|
---|
433 | else
|
---|
434 | return 0;/* Error!! */
|
---|
435 |
|
---|
436 | /* Check if it's an audio file thus playable */
|
---|
437 | if(contentObject->somIsA(mmCDTrackClass))
|
---|
438 | notFound=FALSE;
|
---|
439 | else
|
---|
440 | /* Try next object */
|
---|
441 | mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD, mrc,
|
---|
442 | MPFROM2SHORT(CMA_PREV,CMA_ITEMORDER));
|
---|
443 | };
|
---|
444 | if(!mrc)
|
---|
445 | return 0;
|
---|
446 |
|
---|
447 | break;
|
---|
448 | default:
|
---|
449 | return 0;
|
---|
450 | }/* switch */
|
---|
451 |
|
---|
452 | if(!getMessage(chrCommand, IDSTR_STARTINGTRACK, sizeof(chrCommand), queryResModuleHandle(), hwndFrame))
|
---|
453 | sprintf(chrCommand, "Starting track...");
|
---|
454 | setPlayTimeText2(this, chrCommand);
|
---|
455 |
|
---|
456 | strncpy(chrDevice,"CDAUDIO", sizeof(chrDevice));
|
---|
457 |
|
---|
458 | PSZ pszObjectID;
|
---|
459 | if((pszObjectID=wpQueryObjectID())!=NULLHANDLE) {
|
---|
460 | int iNumCD;
|
---|
461 | char chrFirstCD;
|
---|
462 |
|
---|
463 | strncpy(chrCommand, pszObjectID,sizeof(chrCommand));
|
---|
464 | chrCommand[sizeof(chrCommand)-1]=0;
|
---|
465 | if(CDQueryCDDrives(&iNumCD, &chrFirstCD))
|
---|
466 | sprintf(chrDevice,"CDAUDIO%02d", chrCommand[strlen(chrCommand)-2]-chrFirstCD+1);
|
---|
467 | }
|
---|
468 |
|
---|
469 | chrDevice[sizeof(chrDevice)-1]=0;
|
---|
470 |
|
---|
471 | /* Get track num */
|
---|
472 | if(!methodPtrCDTrack)
|
---|
473 | somhlpQueryCWCDTrackMethodPtr(this);
|
---|
474 | if(methodPtrCDTrack)
|
---|
475 | iTime2=methodPtrCDTrack((MMCDTrack*)contentObject, NULLHANDLE, 0, IDINFO_TRACKNUM);
|
---|
476 | if(methodPtrCDTrack && currentObject)
|
---|
477 | iPrevTrack=methodPtrCDTrack((MMCDTrack*)currentObject, NULLHANDLE, 0, IDINFO_TRACKNUM);
|
---|
478 |
|
---|
479 | // HlpWriteToTrapLog("PrevTrack: %d new track: %d\n", iPrevTrack, iTime2);
|
---|
480 |
|
---|
481 | if(iPrevTrack+1!=iTime2 || !mrcPlaying) {
|
---|
482 | iWave=iWavePriv;
|
---|
483 |
|
---|
484 | /* Start audio file */
|
---|
485 | sprintf(chrCommand,"open \"%s\" alias wave%d SHAREABLE wait", chrDevice, iWavePriv);
|
---|
486 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), playControlDialogFromFrameHWND(hwndFrame), 0);
|
---|
487 |
|
---|
488 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS)
|
---|
489 | return 0;
|
---|
490 |
|
---|
491 | /* Set volume */
|
---|
492 | sprintf(chrCommand,"SET wave%d AUDIO VOLUME %d wait", iWavePriv, ulVolume);
|
---|
493 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
494 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
495 | sprintf(chrCommand,"close wave%d",iWavePriv);
|
---|
496 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
497 | return 0;
|
---|
498 | }
|
---|
499 |
|
---|
500 | sprintf(chrCommand,"SET wave%d TIME FORMAT TMSF wait", iWavePriv);
|
---|
501 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
502 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
503 | sprintf(chrCommand,"close wave%d wait",iWavePriv);
|
---|
504 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
505 | return 0;
|
---|
506 | }
|
---|
507 |
|
---|
508 | //sprintf(chrCommand,"play wave%d FROM %d TO %d", iWavePriv, iTime2, iTime2+1);
|
---|
509 | sprintf(chrCommand,"play wave%d FROM %d ", iWavePriv, iTime2);
|
---|
510 | // HlpWriteToTrapLog(chrCommand);
|
---|
511 | // HlpWriteToTrapLog("\niTime2: %d\n", iTime2);
|
---|
512 |
|
---|
513 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
514 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
515 | sprintf(chrCommand,"close wave%d",iWavePriv);
|
---|
516 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
517 | return 0;
|
---|
518 | }
|
---|
519 | }/* if( ...|| !mrcPlaying) */
|
---|
520 |
|
---|
521 | if(iPrevTrack+1==iTime2) {
|
---|
522 | /* Previous track ended, now playing the next. Or user pressed 'Next' while playing */
|
---|
523 | if(ulPos*1000 < ulTotalLength) {
|
---|
524 | WinStopTimer(WinQueryAnchorBlock(hwndFrame), playControlDialogFromFrameHWND(hwndFrame), IDTIMER_PLAY);
|
---|
525 | sprintf(chrCommand,"SET wave%d TIME FORMAT TMSF wait", iWave);
|
---|
526 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
527 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
528 | sprintf(chrCommand,"close wave%d wait",iWave);
|
---|
529 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
530 | return 0;
|
---|
531 | }
|
---|
532 |
|
---|
533 | sprintf(chrCommand,"play wave%d FROM %d ", iWave, iTime2);
|
---|
534 | // HlpWriteToTrapLog(chrCommand);
|
---|
535 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
536 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
537 | sprintf(chrCommand,"close wave%d",iWavePriv);
|
---|
538 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
539 | return 0;
|
---|
540 | }
|
---|
541 | // HlpWriteToTrapLog("\n2\n");
|
---|
542 | }
|
---|
543 | }
|
---|
544 |
|
---|
545 | // HlpWriteToTrapLog("About to get length...\n");
|
---|
546 |
|
---|
547 | /* Get length in ms */
|
---|
548 | if(!methodPtrCDTrack)
|
---|
549 | somhlpQueryCWCDTrackMethodPtr(this);
|
---|
550 | if(methodPtrCDTrack){ /* Query playtime in secs */
|
---|
551 | iTime2=methodPtrCDTrack((MMCDTrack*)contentObject, NULLHANDLE, 0, IDINFO_PLAYTIME);
|
---|
552 | }
|
---|
553 |
|
---|
554 | // HlpWriteToTrapLog("iTime2: %d\n", iTime2);
|
---|
555 |
|
---|
556 | sprintf(chrCommand,"%d:%02d %d:%02d -%d:%02d", iTime2/60, iTime2%60,
|
---|
557 | 0, 0,
|
---|
558 | iTime2/60, iTime2%60);
|
---|
559 |
|
---|
560 | // HlpWriteToTrapLog("chrCommand: %s\n", chrCommand);
|
---|
561 |
|
---|
562 | // WinSetWindowText(WinWindowFromID(hwndTop, IDST_PLAYTIME), chrCommand);
|
---|
563 | // WinSetWindowText(playTimeControlFromFrameHWND(HWND hwndFrame), chrCommand);
|
---|
564 | ulTotalLength=iTime2*1000; /* convert to ms */
|
---|
565 | // HlpWriteToTrapLog("ulTotalLength: %d\n", ulTotalLength);
|
---|
566 |
|
---|
567 | /* Set emphasis by adding the object to the inuse list */
|
---|
568 | memset(&myViewItem, 0,sizeof(myViewItem));
|
---|
569 | myViewItem.useItem.type=USAGE_OPENVIEW;
|
---|
570 | myViewItem.viewItem.view=OPEN_PLAYING;
|
---|
571 |
|
---|
572 | // HlpWriteToTrapLog("Adding to inuse list\n");
|
---|
573 | WPObject* wpObject=cwGetFileSystemObject(tempObject);
|
---|
574 | // HlpWriteToTrapLog("wpObject: %x somIsObj(wpObject): %x \n", wpObject, somIsObj(wpObject));
|
---|
575 |
|
---|
576 |
|
---|
577 | if(!myViewItem.bIsInUseList) {
|
---|
578 | if(wpObject->wpAddToObjUseList(&myViewItem.useItem))
|
---|
579 | myViewItem.bIsInUseList=TRUE;
|
---|
580 | };
|
---|
581 |
|
---|
582 | /* Select the object */
|
---|
583 | WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(mrc),
|
---|
584 | MPFROM2SHORT(TRUE, CRA_SELECTED));
|
---|
585 |
|
---|
586 | /* Start pos timer. SET MCIPOSITIONADVICE fails when seeking in the wave.
|
---|
587 | Don't know why. */
|
---|
588 | WinStartTimer(WinQueryAnchorBlock(hwndFrame), playControlDialogFromFrameHWND(hwndFrame),
|
---|
589 | IDTIMER_PLAY, PLAYTIMER_DELAY);
|
---|
590 |
|
---|
591 | currentObject=wpObject;
|
---|
592 | mrcPlaying=mrc;
|
---|
593 | /* The start position of the play command */
|
---|
594 | ulStartPosition=0;
|
---|
595 | ulPos=0;
|
---|
596 | bPaused=FALSE;
|
---|
597 | return 0;
|
---|
598 | }
|
---|
599 |
|
---|
600 |
|
---|
601 | BOOL CWCDFolder::cwSeekAudioFile(LONG lPosMSSec)
|
---|
602 | {
|
---|
603 | char chrCommand[50];
|
---|
604 | char retMsg[20];
|
---|
605 | APIRET rc;
|
---|
606 | int iCurrentTrack;
|
---|
607 | ULONG ulPosTrack;
|
---|
608 |
|
---|
609 | sprintf(chrCommand,"SET wave%d TIME FORMAT MS wait", iWave);
|
---|
610 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
611 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
612 | return 0;
|
---|
613 | }
|
---|
614 |
|
---|
615 | sprintf(chrCommand,"STATUS wave%d CURRENT TRACK WAIT", iWave);
|
---|
616 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
617 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
618 | return FALSE;
|
---|
619 | }
|
---|
620 | iCurrentTrack=atoi(retMsg);
|
---|
621 |
|
---|
622 | sprintf(chrCommand,"STATUS wave%d POSITION TRACK %d WAIT", iWave, iCurrentTrack);
|
---|
623 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
624 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
625 | /* Problem with MCI. Clean up. The Timer will be stopped in the method */
|
---|
626 | return FALSE;
|
---|
627 | }
|
---|
628 | ulPosTrack=atoi(retMsg);
|
---|
629 |
|
---|
630 | sprintf(chrCommand,"PLAY wave%d from %d ", iWave, lPosMSSec+ulPosTrack);
|
---|
631 | rc=mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
632 | ulStartPosition=lPosMSSec/1000;
|
---|
633 | bPaused=FALSE;
|
---|
634 |
|
---|
635 | #if 0
|
---|
636 | sprintf(chrCommand,"STATUS wave%d POSITION IN TRACK WAIT", iWave);
|
---|
637 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
638 | if((rc & 0x0000ffff)==MCIERR_SUCCESS) {
|
---|
639 | /* Problem with MCI. Clean up. The Timer will be stopped in the method */
|
---|
640 | ulPos=atoi(retMsg)/1000;
|
---|
641 | }
|
---|
642 | #endif
|
---|
643 |
|
---|
644 | ulPos=lPosMSSec/1000;
|
---|
645 |
|
---|
646 | sprintf(chrCommand,"SET wave%d TIME FORMAT TMSF wait", iWave);
|
---|
647 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
648 |
|
---|
649 | return TRUE;
|
---|
650 | }
|
---|
651 |
|
---|
652 | void CWCDFolder::cwPlayTimeCallback(HWND hwndFrame, LONG lPosSec)
|
---|
653 | {
|
---|
654 | char chrCommand[50];
|
---|
655 | char retMsg[20];
|
---|
656 | ULONG rc;
|
---|
657 | int iPrevTrack;
|
---|
658 | int iCurrentTrack;
|
---|
659 |
|
---|
660 | sprintf(chrCommand,"STATUS wave%d MODE WAIT", iWave);
|
---|
661 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
662 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
663 | /* Problem with MCI. Clean up. The Timer will be stopped in the method */
|
---|
664 | cwStopAudioFile(hwndFrame);
|
---|
665 | return;
|
---|
666 | }
|
---|
667 | else
|
---|
668 | if(!stricmp(retMsg, "stopped")) {
|
---|
669 | /* Audio file played. Start next */
|
---|
670 | cwPlayAudioFile(hwndFrame, PLAY_NEXT);
|
---|
671 | showPlayTimeDisplay(this, TRUE);/* Ensure display is visible */
|
---|
672 | return;
|
---|
673 | }
|
---|
674 |
|
---|
675 | /* Get track num */
|
---|
676 | if(!methodPtrCDTrack)
|
---|
677 | somhlpQueryCWCDTrackMethodPtr(this);
|
---|
678 | if(methodPtrCDTrack && currentObject)
|
---|
679 | iPrevTrack=methodPtrCDTrack((MMCDTrack*)currentObject, NULLHANDLE, 0, IDINFO_TRACKNUM);
|
---|
680 |
|
---|
681 | sprintf(chrCommand,"STATUS wave%d CURRENT TRACK WAIT", iWave);
|
---|
682 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
---|
683 | // HlpWriteToTrapLog("Track: %d, retmsg: %s\n", iPrevTrack, retMsg);
|
---|
684 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
---|
685 | /* Problem with MCI. Clean up. The Timer will be stopped in the method */
|
---|
686 | cwStopAudioFile(hwndFrame);
|
---|
687 | }
|
---|
688 | else {
|
---|
689 | iCurrentTrack=atoi(retMsg);
|
---|
690 | /* Timeout. Check if track is still playing */
|
---|
691 | if(iCurrentTrack==iPrevTrack+1) {
|
---|
692 | /* Audio file played. Start next */
|
---|
693 | cwPlayAudioFile(hwndFrame, PLAY_NEXT);
|
---|
694 | }
|
---|
695 | }
|
---|
696 | }
|
---|
697 |
|
---|
698 |
|
---|
699 |
|
---|
700 |
|
---|
701 |
|
---|
702 |
|
---|
703 |
|
---|
704 |
|
---|
705 |
|
---|