Changeset 165


Ignore:
Timestamp:
Mar 27, 2024, 10:32:40 PM (17 months ago)
Author:
gyoung
Message:

Changes to avoid opening winos2/mplayer.exe; Add avi, mov and jpeg to the file types opened by a modern video player. Use the generic video icon when the modern video player is used; quiet the screen when mplayer is used; get mplayer and ffplay to close when video is finished

Location:
trunk/classes/c
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/classes/c/c_common/helper.c

    r104 r165  
    5353
    5454HMODULE queryModuleHandle(void);
    55 
     55void writeLog(const char* chrFormat, ...);
    5656
    5757MRESULT EXPENTRY appTerminateHandlerProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
     
    102102  }
    103103  /* Start the application */
    104   happ = WinStartApp( hwndAppTerminateHandler, &pDetails,NULL, NULL, SAF_INSTALLEDCMDLINE);
    105   // happ = WinStartApp( hwndAppTerminateHandler, &pDetails, parameters, NULL, 0);
     104  if(strstr(strlwr(parameters), "mplayer") /*|| strstr(strlwr(parameters), "ffplay")*/)
     105    happ = WinStartApp( hwndAppTerminateHandler, &pDetails, NULL, NULL, SAF_INSTALLEDCMDLINE | SAF_MINIMIZED);
     106  else
     107    happ = WinStartApp( hwndAppTerminateHandler, &pDetails, NULL, NULL, SAF_INSTALLEDCMDLINE);
     108  //happ = WinStartApp( hwndAppTerminateHandler, &pDetails, parameters, NULL, 0);
    106109  if(happ) {
    107110    /* Application started. Add the object to inuse list. */
  • trunk/classes/c/c_video/cwavi.c

    r108 r165  
    4242#include <os2.h>
    4343#include <stdarg.h>
    44 #include <stdio.h> 
     44#include <stdio.h>
    4545#include "helpid.h"
    4646#include "cwavi.ih"
     
    5252BOOL getMessage(char* text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd);
    5353ULONG launchPMProg(PSZ pszTitle, PSZ wrapperExe, PSZ parameters,  CWMMDataFile *thisPtr, ULONG ulView);
    54 
     54void writeLog(const char* chrFormat, ...);
    5555
    5656/*
     
    7575        {
    7676          char chrPlayer[CCHMAXPATH]={0};
    77           char chrParams[CCHMAXPATH+2]="\"";
    78           char chrTempParams[CCHMAXPATH+2]={0};
     77          char chrParams[(CCHMAXPATH*2)+2]="\"";
     78          char chrTempParams[(CCHMAXPATH*2)+2]={0};
    7979          char chrTitle[50];
    80           char *chrPtr=chrParams;
     80          char *chrPtr=chrParams;
    8181          ULONG ulSize;
    82           ULONG ulRc;
    83           char szFullFilename[CCHMAXPATH];
     82          ULONG ulRc = 0;
     83          char szFullFilename[CCHMAXPATH]={0};
     84          BOOL ffplay=FALSE;
     85          BOOL found=FALSE;
    8486
    8587          chrPtr++;
     
    8890          strcat(chrPtr,"\"");
    8991          strcpy(chrTempParams, chrParams);
    90           ulSize =PrfQueryProfileInt(HINI_USERPROFILE, "CWMM", "nomodvid", 0);
    91           if(strstr(strlwr(chrTempParams), ".avi")) {
     92          ulSize=PrfQueryProfileInt(HINI_USERPROFILE, "CWMM", "nomodvid", 0);
     93          if(ulSize && strstr(strlwr(chrTempParams), ".avi")) {
    9294            if(!PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "aviplayer", NULLHANDLE, chrPlayer,
    9395                                      sizeof(chrPlayer)))
     
    9597                                    sizeof(chrPlayer));
    9698          }
    97           else if(!ulSize) {
    98             if(!PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "mvidplayer", NULLHANDLE, chrPlayer,
    99                                       sizeof(chrPlayer))) {
    100               if(!DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | SEARCH_CUR_DIRECTORY,
    101                                "PATH",
    102                                "ffplay.exe",
    103                                (PBYTE) szFullFilename,
    104                                 CCHMAXPATH - 1))
    105                 strcpy(chrPlayer, szFullFilename);
    106               else if(!DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | SEARCH_CUR_DIRECTORY,
    107                                      "PATH",
    108                                      "smplayer.exe",
    109                                      (PBYTE) szFullFilename,
    110                                      CCHMAXPATH - 1))
    111                 strcpy(chrPlayer, szFullFilename);
    112              else if(!DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | SEARCH_CUR_DIRECTORY,
    113                                      "PATH",
    114                                      "mplayer.exe",
    115                                      (PBYTE) szFullFilename,
    116                                      CCHMAXPATH - 1))
    117                strcpy(chrPlayer, szFullFilename);
    118              else  {
    119                char text[300];
    120                sprintf(text, "No suitable video player could be found. Please install ffplay (part of ffmpeg) or smplayer/mplayer somewhere in your path or in OS2.INI add the key mvidplayer under CWMM application containing the full path to an appropriate video player");
     99          else {
     100            ULONG ulLength = PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "mvidplayer", NULLHANDLE, chrPlayer,
     101                                  sizeof(chrPlayer));
     102            if((ulLength == 0) || (!strchr(chrPlayer, ":") && (!strstr(strlwr(chrPlayer), "smplayer") &&
     103                                                               strstr(strlwr(chrPlayer), "mplayer")))) {
     104              char tempFilePath[CCHMAXPATH];
     105              char newPath[2048];
     106              char *path;
     107
     108              //Prevent us from getting the mplayer.exe in the winos2 directory
     109              path=getenv("PATH");
     110              strcpy(newPath, path);
     111              chrPtr=strstr(strlwr(newPath), ":\\os2\\mdos\\winos2");
     112              if(chrPtr)
     113                strcpy(chrPtr - 1, chrPtr + 18);
     114              path = strtok(newPath, ";");
     115              while(path != NULL) {
     116                strcpy(tempFilePath, path);
     117                strcat(tempFilePath, "\\mplayer.exe");
     118                if(!DosQueryPathInfo(tempFilePath, FIL_STANDARD, (PVOID)szFullFilename, (ULONG)CCHMAXPATH-1)) {
     119                  strcpy(chrPlayer, tempFilePath);
     120                  found=TRUE;
     121                  break;
     122                }
     123                path = strtok(NULL, ";");
     124              }
     125            }
     126            if(!ulLength && !found &&
     127               !DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | SEARCH_CUR_DIRECTORY, "PATH",
     128                              "smplayer.exe", (PBYTE) szFullFilename, CCHMAXPATH - 1)){
     129              found=TRUE;
     130              strcpy(chrPlayer, szFullFilename);
     131            }
     132            if(!ulLength && !found &&
     133               !DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | SEARCH_CUR_DIRECTORY, "PATH",
     134                                                     "ffplay.exe", (PBYTE) szFullFilename, CCHMAXPATH - 1)) {
     135              found=TRUE;
     136              strcpy(chrPlayer, szFullFilename);
     137            }
     138            if(!ulLength && !found)  {
     139              char text[300];
     140              sprintf(text, "No suitable video player could be found. Please install ffplay (part of ffmpeg)"\
     141                      "or smplayer/mplayer somewhere in your path or in OS2.INI add the key mvidplayer"\
     142                      "under CWMM application containing the full path to an appropriate video player");
    121143 
    122                WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "Missing video player",
    123                              1234, MB_OK|MB_MOVEABLE);
    124                return NULLHANDLE;
    125              }
    126             }
     144              WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "Missing video player",
     145                            1234, MB_OK|MB_MOVEABLE);
     146              return NULLHANDLE;
     147           }
     148          }
     149          /* Eliminate the noise with mplayer and ffplay and get them to close gracefully*/
     150          if(strstr(strlwr(chrPlayer), "ffplay"))
     151            ffplay = TRUE;
     152          if((!strstr(strlwr(chrPlayer), "smplayer") && strstr(strlwr(chrPlayer), "mplayer")) || ffplay) {
     153            strcpy(chrTempParams, " /c \"");
     154            strcat(chrTempParams, chrPlayer);
     155            strcat(chrTempParams, " ");
     156            if(ffplay)
     157              strcat(chrTempParams, "-autoexit ");
     158            strcat(chrTempParams, chrParams);
     159            strcat(chrTempParams, "\"");
     160            strcpy(chrParams, chrTempParams);
     161            strcpy(chrPlayer, "CMD.EXE");
    127162          }
    128163          /* Get the Title for the window list */
     
    131166
    132167          if((ulRc=launchPMProg(chrTitle, chrPlayer, chrParams, somSelf, ulView))==NULLHANDLE) {
    133             break;
     168            break;
    134169          }
    135           return NULLHANDLE;
     170          return NULLHANDLE;
    136171        }
    137172      default:
    138173        break;
    139174      }
    140 
    141     return (MMAVI_parent_MMVideo_wpOpen(somSelf, hwndCnr, ulView,
    142                                         param));
     175    return (MMAVI_parent_MMVideo_wpOpen(somSelf, hwndCnr, ulView, param));
    143176}
    144177
     
    184217      return "AVI";
    185218    else
    186     return "AVI/FLV/3GP/M4V/MKV/MP4/MTS/VOB/WMV/WEBM";
     219    return "AVI/FLV/3GP/M4V/MKV/MOV/MP4/MPEG/MTS/VOB/WMV/WEBM";
    187220}
    188221
     
    202235    M_MMAVIMethodDebug("M_MMAVI","cwaviM_wpclsQueryInstanceFilter");
    203236
    204     ulSize =PrfQueryProfileInt(HINI_USERPROFILE, "CWMM", "nomodvid", 0);
     237    ulSize=PrfQueryProfileInt(HINI_USERPROFILE, "CWMM", "nomodvid", 0);
    205238    if(ulSize)
    206239      return "*.AVI";
    207240    else
    208       return "*.AVI,*.FLV,*.3GP,*.M4V,*.MKV,*.MP4,*.MTS,*.VOB,*.WMV,*.WEBM";
     241      return "*.AVI,*.FLI,*.FLC,*.FLV,*.3GP,*.M4V,*.MKV,*.MOV,*.MP4,*.MPEG,*.MTS,*.VOB,*.WMV,*.WEBM";
    209242}
    210243
     
    229262      return M_MMAVI_parent_M_MMVideo_wpclsQueryIconData(somSelf, pIconInfo);
    230263
    231         if (pIconInfo)   {
     264    if(pIconInfo)   {
     265      ULONG ulSize=PrfQueryProfileInt(HINI_USERPROFILE, "CWMM", "nomodvid", 0);
    232266      pIconInfo->fFormat = ICON_RESOURCE;
    233267      pIconInfo->hmod    = hmod;
    234       pIconInfo->resid   = ID_ICONAVIFILE;
    235         } /* endif */
     268      if(ulSize)
     269        pIconInfo->resid   = ID_ICONAVIFILE;
     270      else
     271        pIconInfo->resid   = ID_ICONCWVIDEOFILE;
     272    } /* endif */
    236273
    237274        return ( sizeof(ICONINFO) );
Note: See TracChangeset for help on using the changeset viewer.