The original class only has the play, pause and stop functionality. pointers with the same dereferenced value.īool SetPositions(_int64* pCurrent, _int64* pStop, bool bAbsolutePositioning) avoid putting the same pointer into both of them, meaning put different Note: Even if pCurrent and pStop have the same value, If pCurrent and pStop have the same value, the player will seek to the position bAbsolutePositioning specifies absolute or relative positioning. Seek to position with pCurrent and pStop You have to divide the result by 10,000,000 Returns the duration in 1/10 millionth of a second, -10000 is lowest volume and 0 is highest volume -10000 is lowest volume and 0 is highest volume, positive value > 0 will fail If the mp3 finished playing, WaitForCompletion will return true īool WaitForCompletion(long msTimeout, long* EvCode) Poll this function with msTimeout = 0, so that it return immediately. #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers And you have to also call CoUninitialize at the end of your application, after the Cleanup is called. You have to call COM’s CoInitialize to initialize COM’s runtime before calling the Load on mp3 file. If you are using Visual Studio 2010, it actually comes with a subset of the Windows SDK, which includes the DirectShow libraries, so you can build this class without downloading anything. Since this class relies on DirectShow, you need to download the Windows SDK to build it.
#Musicplayer getcurrentposition code#
The original code needs a bit of tweaking to include the necessary header files and import libraries so that it will compile in Visual Studio 2010. The original code is from Flipcode‘s contributor, Alan Kemp. If you need to just play MP3s in your application (for example, play a short MP3 during the application splash screen), Mp3 class is a no frills C++ MP3/WMA DirectShow player class, for such simple needs.