Playback control by mutex and map file

Parent Previous Next

Playback control by mutex and map file


C++ code samples

Check the running player

HANDLE hMutex;

UnicodeString INSTANCE="sample";

hMutex=OpenMutex(MUTEX_ALL_ACCESS,false,UnicodeString("TABS_VIDEO_PLAYER_"+INSTANCE).w_str());

if (hMutex!=NULL) {

// Player already runing

}

Launch player

First way

system("C:\\TabsVideoPlayer\\TabsVideoPlayer.exe sample XXX \"Y:\\My files\\video\\sample.mkv\" 10 100 3600");

Second way

ShellExecute(Handle,L"open",UnicodeString("C:\\TabsVideoPlayer\\TabsVideoPlayer.exe").w_str(),"sample XXX \"Y:\\My files\\video\\sample.mkv\" 10 100 3600",NULL,SW_SHOWNORMAL);

Opening video with parameters

We believe that the player is already running.


HANDLE hMapFile;

UnicodeString INSTANCE="sample",s ;

hMapFile=OpenFileMapping(FILE_MAP_ALL_ACCESS,FALSE,UnicodeString("TABS_VIDEO_PLAYER_DATA_"+INSTANCE).w_str());

if (hMapFile!=NULL) {

pBuf = (LPTSTR) MapViewOfFile(hMapFile,FILE_MAP_ALL_ACCESS,0,0,2002);

       if (pBuf!=NULL) {

               // Make parameters (Tab File [Speed] [Volume] [Position])

               s="XXX \"Y:\\My files\\video\\sample.mkv\" 10 100 3600";

               CopyMemory((PVOID)pBuf,s.w_str(),s.Length()*2+2); // Copy to shared memory

               UnmapViewOfFile(pBuf);

       }

CloseHandle(hMapFile);

}



Created with the Personal Edition of HelpNDoc: Free HTML Help documentation generator