MPlayer0623

所属分类:Windows编程
开发工具:Visual C++
文件大小:113KB
下载次数:128
上传日期:2006-04-19 10:27:46
上 传 者oilking
说明:  windows下自制的媒体播放器,很漂亮,模拟液晶显示,播放多种媒体
(made under the windows media player, a very nice, analog LCD, various media players)

文件列表:
MPlayer0126 (0, 2003-02-14)
MPlayer0126\AlexfMixer.cpp (5311, 1999-05-17)
MPlayer0126\AlexfMixer.h (3801, 1999-05-17)
MPlayer0126\AlexfVolume doc.txt (1956, 2003-01-26)
MPlayer0126\BtnST.cpp (59306, 2003-01-12)
MPlayer0126\BtnST.h (9852, 2003-01-11)
MPlayer0126\ClassMembers-MatrixStatic.txt (11660, 2002-11-08)
MPlayer0126\IVolume.h (796, 1998-11-24)
MPlayer0126\MatrixStatic.cpp (11442, 2002-11-10)
MPlayer0126\MatrixStatic.h (5149, 2002-11-10)
MPlayer0126\Media.cpp (8754, 2003-01-26)
MPlayer0126\Media.h (1820, 2003-01-25)
MPlayer0126\MPlayer.clw (2869, 2003-01-26)
MPlayer0126\MPlayer.cpp (2077, 2003-01-12)
MPlayer0126\MPlayer.dsp (5127, 2003-01-26)
MPlayer0126\MPlayer.dsw (537, 2003-01-12)
MPlayer0126\MPlayer.h (1335, 2003-01-12)
MPlayer0126\MPlayer.rc (7802, 2003-01-26)
MPlayer0126\MPlayerDlg.cpp (18769, 2003-01-26)
MPlayer0126\MPlayerDlg.h (3548, 2003-01-26)
MPlayer0126\MySliderControl.cpp (7654, 2003-01-12)
MPlayer0126\MySliderControl.h (4220, 2003-01-13)
MPlayer0126\Release (0, 2003-02-14)
MPlayer0126\res (0, 2003-02-14)
MPlayer0126\resource.h (1782, 2003-01-26)
MPlayer0126\res\ext.bmp (308, 2003-01-18)
MPlayer0126\res\matrixsetblue.bmp (31798, 2003-01-14)
MPlayer0126\res\matrixsetsmallblue.bmp (17014, 2003-01-14)
MPlayer0126\res\matrixsettinyblue.bmp (8038, 2003-01-14)
MPlayer0126\res\MPlayer.bmp (164616, 2003-01-19)
MPlayer0126\res\MPlayer.ico (1078, 2003-01-12)
MPlayer0126\res\MPlayer.rc2 (399, 2003-01-12)
MPlayer0126\res\n-ext.bmp (308, 2003-01-18)
MPlayer0126\StdAfx.cpp (209, 2003-01-12)
MPlayer0126\StdAfx.h (1191, 2003-01-13)
MPlayer0126\VolumeOutWave.cpp (15125, 1998-11-24)
MPlayer0126\VolumeOutWave.h (1585, 1998-08-19)

Many times my applications required audio volume manipulation. To make the volume-enabled application development easier I decided to create a few C++ classes that would allow me to easily regulate and track the changes of such volume controls as Output Master Volume, WaveOut Volume and Input (WaveIn) Volume. Here I provide such classes that share a common interface (defined in IVolume.h): bool IsAvailable() - Says whether the volume controling is possible void Enable() - Enables the line of the volume control void Disable() - Disables the line of the volume control DWORD GetVolumeMetric() - Retrieves the granularity of volume DWORD GetMinimalVolume() - Retrieves the minimal volume that can be set DWORD GetMaximalVolume() - Retrieves the maximal volume that can be set DWORD GetCurrentVolume() - Retrieve the current volume void SetCurrentVolume( DWORD dwValue ) - Set the volume And the last function allows to register a user-implemented callback that will be called as a notification of volume changes: void RegisterNotificationSink( PONMICVOULUMECHANGE, DWORD ) This interface is implemented by CVolumeOutMaster (VolumeOutMaster.h/cpp), CVolumeOutWave (VolumeOutWave.h/cpp) and CVolumeInXXX (VolumeInXXX.h/cpp) classes. The usage of the classes is very simple: In your StdAfx.h include "mmSystem.h" and make sure you link to the "winmm.lib" ( #pragma comment(lib, "winmm.lib") ). Then, if you are going to use Output Mater volume control, include "VolumeOutMaster.h", say, to the StdAfx.h The IVolume.h, VolumeInXXX.h, VolumeInXXX.cpp are to be inserted as your project files. ... void CALLBACK MasterVolumeChanged( DWORD dwCurrentVolume, DWORD dwUserValue ); ... // Volume control Initialization IVolume* pMasterVolume = (IVolume*)new CVolumeOutMaster(); if ( !pMasterVolume || !pMasterVolume->IsAvailable() ) { // handle error } pMasterVolume->Enable(); pMasterVolume->RegisterNotificationSink( MasterVolumeChanged, dwAnyUserValue ); ... pMasterVolume->SetCurrentVolume( dwVolumeToSet ); ... DWORD dwCurrentVolume = pMasterVolume->SetCurrentVolume(); ... void CALLBACK MasterVolumeChanged( DWORD dwCurrentVolume, DWORD dwUserValue ) { // handle the volume change } ... Very simple, isn't it? Yet, the CVolumeInXXX class requires more explanation. In order to manipulate the Input volume, the source line index is to be passed to the constructor. Confused? Please, be not. CVolumeInXXX class provides a static function to enumerate those lines: bool EnumerateInputLines( PINPUTLINEPROC, DWORD dwUserValue ); This allows you to manipulate the volume of any WaveIn-based lines. Say, you want to manipulate the microphone volume: ... bool CALLBACK EnumInputLineProc( UINT uLineIndex, MIXERLINE* pLineInfo, DWORD dwUserValue ); ... // Initialization UINT uMicrophoneLineIndex = (UINT)-1; if ( !CVolumeInXXX::EnumerateInputLines( EnumInputLineProc, (DWORD)&uMicrophoneLineIndex ) ) { // handle error } if ( uMicrophoneLineIndex == (UINT)-1 ) { // Error: mic volume'ing is not available. } IVolume* pMicrophoneVolume = (IVolume*)new CVolumeInXXX( uMicrophoneLineIndex ); if ( !pMicrophoneVolume || !pMicrophoneVolume->IsAvailable() ) { // handle error } // Go on and use pMicrophoneVolume to manipulate the volume ... bool CALLBACK EnumInputLineProc( UINT uLineIndex, MIXERLINE* pLineInfo, DWORD dwUserValue ) { if ( pLineInfo->dwComponentType == MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE ) { *((UINT*)dwUserValue) = uLineIndex; return false; } return true; } ... Be aware, that for performance reasons it is better to have a single instance of a given class per application. So don't rush to create lots of CVolumeInXXX objects, better share the only one through your code. Conclusion: The proposed classes do not encapsulate all the abilities exposed by the mixers. However, working with a mixer just to add a pretty simple functionality is quite boring. That's why, as I think, the proposed classes might be of some help to you.

近期下载者

相关文件


收藏者