Changeset 133 for trunk/mediafolder/c/mediafldr/mediafolder.cpp
- Timestamp:
- Nov 29, 2023, 5:59:34 PM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mediafolder/c/mediafldr/mediafolder.cpp
r57 r133 1 1 /* 2 2 * This file is (C) Chris Wohlgemuth 2002 3 * 3 * 4 4 * It's part of the Media-Folder distribution 5 5 */ … … 69 69 switch(ulAction) 70 70 { 71 case PLAY_FIRST: 71 case PLAY_FIRST: 72 72 /* Send a message to the object window created by the folder play thread */ 73 73 WinPostMsg(thisPtr->mfData->hwndPlayObject,WM_APPTERMINATENOTIFY, 0,MPFROMLONG(PLAY_FIRST)); … … 146 146 thisPtr->cwSeekAudioFile(LONGFROMMP(mp1)); 147 147 /* restart timer */ 148 // WinStartTimer(WinQueryAnchorBlock(hwnd), WinWindowFromID(hwndFrame), IDTIMER_PLAY, PLAYTIMER_DELAY); 148 // WinStartTimer(WinQueryAnchorBlock(hwnd), WinWindowFromID(hwndFrame), IDTIMER_PLAY, PLAYTIMER_DELAY); 149 149 thisPtr->ulPos=LONGFROMMP(mp1)/1000; 150 150 } … … 192 192 if(hwnd) { 193 193 thisPtr->mfData->hwndPlayObject=hwnd; 194 WinSetWindowULong(hwnd, QWL_USER,(ULONG)tPt); 194 195 WinSubclassWindow(hwnd,&playObjectProc); 195 WinSetWindowULong(hwnd, QWL_USER,(ULONG)tPt);196 196 /* Window created. */ 197 197 while(WinGetMsg(hab,&qmsg,(HWND)NULL,0,0)) … … 225 225 return; 226 226 227 thisPtr=(CWMediaFolder*)threadParms->thisPtr; 227 thisPtr=(CWMediaFolder*)threadParms->thisPtr; 228 228 229 229 if(!somIsObj(thisPtr)) … … 247 247 if(!((WPFileSystem*)thisPtr->wpObjM3UFile)->wpQueryRealName(chrFileName, &ulSize, TRUE)) 248 248 return; 249 249 250 250 /* Get name of folder */ 251 251 ulSize=CCHMAXPATH; … … 256 256 if(hab) { 257 257 hmq=WinCreateMsgQueue(hab,0); 258 if(hmq) { 258 if(hmq) { 259 259 RXSTRING arg[2]; /* argument string for REXX */ 260 260 RXSTRING rexxretval; /* return value from REXX */ … … 266 266 /* We could provide a buffer for the interpreter to use instead. */ 267 267 rexxretval.strlength = 0L; /* initialize return to empty*/ 268 268 269 269 MAKERXSTRING(arg[0], chrFileName, strlen(chrFileName));/* create input argument */ 270 MAKERXSTRING(arg[1], chrFolderName, strlen(chrFolderName));/* create input argument */ 271 270 MAKERXSTRING(arg[1], chrFolderName, strlen(chrFolderName));/* create input argument */ 271 272 272 TRY_LOUD(RX_START) { 273 273 /* Here we call the interpreter. We don't really need to use */ … … 285 285 (PSHORT) &rexxrc, /* Rexx program output */ 286 286 (PRXSTRING) &rexxretval ); /* Rexx program output */ 287 287 288 288 if(rc) { 289 sprintf(chrFileName,"Error in the Rexx skript %s\n\n Get more information with 'help REX%04d'.\n", 289 sprintf(chrFileName,"Error in the Rexx skript %s\n\n Get more information with 'help REX%04d'.\n", 290 290 "", rc*-1); 291 291 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, chrFileName, "", 1234, MB_OK|MB_MOVEABLE|MB_ERROR); 292 292 } 293 DosFreeMem(rexxretval.strptr); /* Release storage given to us by REXX. */ 293 DosFreeMem(rexxretval.strptr); /* Release storage given to us by REXX. */ 294 294 } 295 295 CATCH(RX_START) 296 296 {}END_CATCH; 297 297 298 298 WinDestroyMsgQueue(hmq); 299 299 } … … 301 301 } 302 302 // thisPtr->fContentsChanged=FALSE; 303 thisPtr->wpFreeMem((PBYTE)chrFileName); 303 thisPtr->wpFreeMem((PBYTE)chrFileName); 304 304 thisPtr->wpFreeMem((PBYTE)threadParms); 305 305 } … … 372 372 373 373 WinSetWindowPos(hwndFrame, NULLHANDLE, swp2.x, swp2.y, swp2.cx,swp2.cy,SWP_SIZE|SWP_MOVE); 374 /* 374 /* 375 375 By changing the to contents view we trick the WPS to show the 'Details view' menu item in 376 376 the view menu of the folders system menu. In that sub menu the WPS always inserts all known … … 379 379 The system knows nothing about the 'compact view' and all the handling is done by us. 380 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'. 381 view isn't changed when the folder is closed in 'Compact view'. 382 382 */ 383 383 wpMenuItemSelected(hwndFrame, 0x2cc); … … 419 419 ",", chrBuf, sizeof(chrBuf)); 420 420 chrBuf[sizeof(chrBuf)-1]=0; 421 421 422 422 if(mfData->ulTotalTime<=3600) { 423 423 getMessage( text, IDSTR_STATUSTIME1, sizeof(text), queryResModuleHandle(), HWND_DESKTOP); … … 432 432 sprintf(time, text, mfData->ulTotalTime/(3600*24), 433 433 (mfData->ulTotalTime%(3600*24))/3600, (mfData->ulTotalTime%3600)/60, mfData->ulTotalTime%60); 434 } 434 } 435 435 if(mfData->ulSize<=0xffffffff) { 436 436 getMessage( text2, IDSTR_STATUSTIME4, sizeof(text2), queryResModuleHandle(),HWND_DESKTOP); 437 sprintf(text, text2, 437 sprintf(text, text2, 438 438 mfData->ulNumTracks, mfData->ulSize/1000000 ,chrBuf, (mfData->ulSize%1000000)/1000, 439 439 chrBuf, mfData->ulSize%1000, … … 488 488 getMessage(pageName, IDSTRSETTING_TOOLBAR, sizeof(pageName), queryResModuleHandle(), hwndNotebook); 489 489 pageinfo.pszName = pageName; 490 490 491 491 //Insert the page into the settings notebook 492 492 return wpInsertSettingsPage(hwndNotebook,&pageinfo); … … 497 497 PMINIRECORDCORE mrc; 498 498 WPObject * contentObject; 499 499 500 500 /* See if we have an audio file played with doubleclick */ 501 501 mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORDEMPHASIS,MPFROMLONG(CMA_FIRST), … … 551 551 /* Get new ID for wave device */ 552 552 if(cwRequestMutex(hmtxFileName, 100000)==ERROR_TIMEOUT) 553 return FALSE; 553 return FALSE; 554 554 555 555 iWaveDev++; … … 565 565 WPObject *wpObject; 566 566 PMINIRECORDCORE pmrc; 567 567 568 568 #if 0 569 569 /* There's already a file playing using doubleclick */ 570 if(mmGetOtherPlayingAudioFile( this, hwndContainer, &wpObject, &pmrc)) 570 if(mmGetOtherPlayingAudioFile( this, hwndContainer, &wpObject, &pmrc)) 571 571 return 0; 572 572 #endif … … 605 605 else 606 606 return 0;/* Error */ 607 608 if( contentObject->somIsA(cwAudioClass) || 607 608 if( contentObject->somIsA(cwAudioClass) || 609 609 /*contentObject->somIsA(mmAudioClass) ||*/ 610 610 contentObject->somIsA(mmMIDIClass)) { … … 643 643 MPFROM2SHORT(CMA_NEXT,CMA_ITEMORDER)); 644 644 645 if((int)mrc==-1) { 645 if((int)mrc==-1) { 646 646 /* Wrong parameter -> user deleted the shadow. */ 647 647 /* Stop wave, remove in use emphasis. */ … … 650 650 } 651 651 // HlpWriteToTrapLog("Next mrc is %x\n", mrc); 652 652 653 653 notFound=TRUE; 654 while(notFound && mrc && (int)mrc!=-1){ 654 while(notFound && mrc && (int)mrc!=-1){ 655 655 contentObject=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object 656 656 if(somIsObj(contentObject)) { … … 664 664 else 665 665 return 0;/* Error */ 666 666 667 667 if(contentObject->somIsA(cwAudioClass) || 668 668 /* contentObject->somIsA(mmAudioClass) || */ … … 701 701 /* Select the object */ 702 702 WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(pmrc), 703 MPFROM2SHORT(TRUE, CRA_SELECTED)); 703 MPFROM2SHORT(TRUE, CRA_SELECTED)); 704 704 705 705 return cwPlayAudioFile(hwndFrame, PLAY_FIRST);/* Not yet playing, so start the first one. */ … … 709 709 return cwPlayAudioFile(hwndFrame, PLAY_FIRST);/* Not yet playing, so start the first one. */ 710 710 } 711 711 712 712 /* Check the current time. If we are at the very beginning of the track skip to the previous track 713 713 otherwise skip to the beginning of the current track. */ … … 727 727 /* Find an audio file */ 728 728 notFound=TRUE; 729 while(notFound && mrc && (int)mrc!=-1){ 729 while(notFound && mrc && (int)mrc!=-1){ 730 730 contentObject=(WPObject*)OBJECT_FROM_PREC(mrc);//Get object 731 731 if(somIsObj(contentObject)) { … … 741 741 742 742 /* Check if it's an audio file thus playable */ 743 if(contentObject->somIsA(cwAudioClass) || 743 if(contentObject->somIsA(cwAudioClass) || 744 744 /* contentObject->somIsA(mmAudioClass) || */ 745 745 contentObject->somIsA(mmMIDIClass)) { … … 755 755 if(!mrc) 756 756 return 0; 757 757 758 758 break; 759 759 default: … … 771 771 else /*if(contentObject->somIsA(cwAudioClass) || contentObject->somIsA(mmAudioClass))*/ 772 772 strncpy(chrDevice,"WAVEAUDIO", sizeof(chrDevice)); 773 773 774 774 chrDevice[sizeof(chrDevice)-1]=0; 775 775 776 776 hwndNotify=playControlDialogFromFrameHWND(hwndFrame);//WinWindowFromID(hwndTop, IDDLG_TOPMIDDLE); 777 777 778 /* Start audio file */ 778 /* Start audio file */ 779 779 sprintf(chrCommand,"open \"%s\" type %s alias wave%d SHAREABLE wait",name, chrDevice, iWavePriv); 780 780 rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), hwndNotify, 0); … … 789 789 rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0); 790 790 return 0; 791 } 791 } 792 792 793 793 sprintf(chrCommand,"SETPOSITIONADVISE wave%d ON EVERY 1000 notify", iWavePriv); … … 829 829 } 830 830 831 /* Start pos timer. SET MCIPOSITIONADVICE fails when seeking in the wave. 831 /* Start pos timer. SET MCIPOSITIONADVICE fails when seeking in the wave. 832 832 Don't know why. */ 833 833 834 //WinStartTimer(WinQueryAnchorBlock(hwndFrame), WinWindowFromID(hwndTop, IDDLG_TOPMIDDLE), IDTIMER_PLAY, PLAYTIMER_DELAY); 834 //WinStartTimer(WinQueryAnchorBlock(hwndFrame), WinWindowFromID(hwndTop, IDDLG_TOPMIDDLE), IDTIMER_PLAY, PLAYTIMER_DELAY); 835 835 WinStartTimer(WinQueryAnchorBlock(hwndFrame), playControlDialogFromFrameHWND(hwndFrame), IDTIMER_PLAY, PLAYTIMER_DELAY); 836 836 … … 849 849 /* Select the object */ 850 850 WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(mrc), 851 MPFROM2SHORT(TRUE, CRA_SELECTED)); 851 MPFROM2SHORT(TRUE, CRA_SELECTED)); 852 852 853 853 iWave=iWavePriv; … … 872 872 BOOL bFound=FALSE; 873 873 874 /** Get a random number in the appropriate range */ 874 /** Get a random number in the appropriate range */ 875 875 DosGetDateTime((PDATETIME)&DT); /* Get the time */ 876 876 seed = DT.hours*60 + DT.minutes; /* convert to hundreths */ … … 885 885 886 886 #ifdef RANDOM_DEBUG 887 HlpWriteToTrapLog("\n Zufall: %d %d\n", zufall, mfData->pRandomArray[zufall]); 887 HlpWriteToTrapLog("\n Zufall: %d %d\n", zufall, mfData->pRandomArray[zufall]); 888 888 #endif 889 889 /* Get a random number in the appropriate range */ … … 891 891 mfData->pRandomArray[zufall]=1; 892 892 #ifdef RANDOM_DEBUG 893 HlpWriteToTrapLog("2 Zufall: %d %d\n", zufall, mfData->pRandomArray[zufall]); 893 HlpWriteToTrapLog("2 Zufall: %d %d\n", zufall, mfData->pRandomArray[zufall]); 894 894 #endif 895 895 return zufall; … … 900 900 if (zufall == start && !bFound) { 901 901 #ifdef RANDOM_DEBUG 902 HlpWriteToTrapLog("Error Zufall: %d %d\n", zufall, mfData->pRandomArray[zufall]); 902 HlpWriteToTrapLog("Error Zufall: %d %d\n", zufall, mfData->pRandomArray[zufall]); 903 903 #endif 904 904 return -1; … … 944 944 /* Check if we currently play the last track. */ 945 945 if((mfData->iNumPlayed>=mfData->iNumToPlay) && mfData->pRandomArray) { 946 cwStopAudioFile(hwndFrame);/* Reset playing vars and remove in use emphasis */ 946 cwStopAudioFile(hwndFrame);/* Reset playing vars and remove in use emphasis */ 947 947 if(!(ulFlags&FLAG_REPEAT)) 948 948 return 0; … … 959 959 /* Get new ID for wave device */ 960 960 if(cwRequestMutex(hmtxFileName, 100000)==ERROR_TIMEOUT) 961 return FALSE; 961 return FALSE; 962 962 iWaveDev++; 963 963 if(iWaveDev==1000) … … 1009 1009 /* Find an audio file */ 1010 1010 notFound=TRUE; 1011 while(notFound){ 1011 while(notFound){ 1012 1012 /* Find track to play */ 1013 1013 if((iTrack=_getRandomTrack(mfData))==-1) { … … 1022 1022 HlpWriteToTrapLog("%s: _getRandomTrack returned: %d.\n", __FUNCTION__, iTrack); 1023 1023 #endif 1024 1024 1025 1025 for(a=0,mrc=(PMINIRECORDCORE)WinSendMsg(hwndContainer,CM_QUERYRECORD,NULL, 1026 1026 MPFROM2SHORT(CMA_FIRST,CMA_ITEMORDER)); … … 1039 1039 #endif 1040 1040 1041 if(!mrc) 1041 if(!mrc) 1042 1042 { 1043 1043 #ifdef RANDOM_DEBUG … … 1053 1053 1054 1054 /* Check if it's an audio file thus playable */ 1055 if(contentObject->somIsA(cwAudioClass) || 1055 if(contentObject->somIsA(cwAudioClass) || 1056 1056 /* contentObject->somIsA(mmAudioClass) ||*/ 1057 1057 contentObject->somIsA(mmMIDIClass)) { … … 1083 1083 else /*if(contentObject->somIsA(cwAudioClass) || contentObject->somIsA(mmAudioClass))*/ 1084 1084 strncpy(chrDevice,"WAVEAUDIO", sizeof(chrDevice)); 1085 1085 1086 1086 chrDevice[sizeof(chrDevice)-1]=0; 1087 1087 1088 1088 hwndNotify=playControlDialogFromFrameHWND(hwndFrame);//WinWindowFromID(hwndTop, IDDLG_TOPMIDDLE); 1089 1089 1090 /* Start audio file */ 1090 /* Start audio file */ 1091 1091 sprintf(chrCommand,"open \"%s\" type %s alias wave%d SHAREABLE wait",name, chrDevice, iWavePriv); 1092 1092 rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), hwndNotify, 0); … … 1100 1100 rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0); 1101 1101 return 0; 1102 } 1102 } 1103 1103 1104 1104 sprintf(chrCommand,"SETPOSITIONADVISE wave%d ON EVERY 1000 notify", iWavePriv); … … 1140 1140 return 0; 1141 1141 } 1142 /* Start pos timer. SET MCIPOSITIONADVICE fails when seeking in the wave. 1142 /* Start pos timer. SET MCIPOSITIONADVICE fails when seeking in the wave. 1143 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); 1144 // WinStartTimer(WinQueryAnchorBlock(hwndFrame), WinWindowFromID(hwndTop, IDDLG_TOPMIDDLE), IDTIMER_PLAY, PLAYTIMER_DELAY); 1145 WinStartTimer(WinQueryAnchorBlock(hwndFrame), playControlDialogFromFrameHWND(hwndFrame), IDTIMER_PLAY, PLAYTIMER_DELAY); 1146 1146 1147 1147 /* Set emphasis by adding the object to the inuse list */ … … 1158 1158 /* Select the object */ 1159 1159 WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(mrc), 1160 MPFROM2SHORT(TRUE, CRA_SELECTED)); 1160 MPFROM2SHORT(TRUE, CRA_SELECTED)); 1161 1161 1162 1162 iWave=iWavePriv; … … 1187 1187 mfData->iNumPlayed=0; 1188 1188 } 1189 1189 1190 1190 sprintf(chrCommand,"stop wave%d wait", iWave); 1191 1191 rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0); 1192 1192 1193 1193 sprintf(chrCommand,"close wave%d wait", iWave); 1194 1194 rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0); 1195 1195 1196 1196 _resetDisplay(this); 1197 1197 //_resetDisplay(topControlFromFrameHWND(hwndFrame)); … … 1207 1207 myViewItem.bIsInUseList=FALSE; 1208 1208 }; 1209 1209 1210 1210 //HlpWriteToTrapLog("\n1 line %d.\n"); 1211 1211 1212 1212 /* Deselect the object */ 1213 1213 if(WinIsWindow(WinQueryAnchorBlock(hwndFrame), hwndContainer)) 1214 1214 WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(mrcPlaying), 1215 MPFROM2SHORT(FALSE, CRA_SELECTED)); 1216 1215 MPFROM2SHORT(FALSE, CRA_SELECTED)); 1216 1217 1217 iWave=0; 1218 1218 currentObject=NULLHANDLE; … … 1234 1234 #endif 1235 1235 WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(mrc), 1236 MPFROM2SHORT(FALSE, CRA_SELECTED)); 1236 MPFROM2SHORT(FALSE, CRA_SELECTED)); 1237 1237 } 1238 1238 #if 0 … … 1258 1258 ulPos=0; 1259 1259 WinSendMsg(hwndContainer,CM_SETRECORDEMPHASIS, MPFROMP(mrc), 1260 MPFROM2SHORT(FALSE, CRA_SELECTED)); 1260 MPFROM2SHORT(FALSE, CRA_SELECTED)); 1261 1261 1262 1262 }; … … 1273 1273 __FUNCTION__, __FILE__, __LINE__); 1274 1274 } END_CATCH; 1275 1275 1276 1276 return TRUE; 1277 1277 } … … 1323 1323 if((rc & 0x0000ffff)!=MCIERR_SUCCESS) { 1324 1324 /* Problem with MCI. Clean up. The Timer will be stopped in the method */ 1325 cwStopAudioFile(hwndFrame); 1325 cwStopAudioFile(hwndFrame); 1326 1326 } 1327 1327 else { 1328 1328 if(!stricmp(retMsg, "stopped")) { 1329 1329 /* Audio file played. Start next */ 1330 cwPlayAudioFile(hwndFrame, PLAY_NEXT); 1330 cwPlayAudioFile(hwndFrame, PLAY_NEXT); 1331 1331 } 1332 1332 showPlayTimeDisplay(this, TRUE);/* Ensure display is visible */
Note:
See TracChangeset
for help on using the changeset viewer.