WinCE 调节MediaPlayer的音量

//头文件与库文件在SDK中查找

#include <decibels.h>
#pragma comment(lib, "ensoniq_lib.lib")

#define MIN_VOLUME_RANGE     0//音量最小比例
#define MAX_VOLUME_RANGE     100//音量最大比例
#define AX_MIN_VOLUME      -10000//音量最小值
#define AX_MAX_VOLUME      0//音量最大值

//从音量百分比算出音量实际数值
LONG VolumeLinToLog(short nLinKnobValue)
{
    LONG lLinMin = DBToAmpFactor(AX_MIN_VOLUME);
    LONG lLinMax = DBToAmpFactor(AX_MAX_VOLUME);

    LONG lLinTemp = (LONG)(nLinKnobValue - MIN_VOLUME_RANGE) * (lLinMax - lLinMin)
        / (MAX_VOLUME_RANGE - MIN_VOLUME_RANGE) + lLinMin;

    LONG lLogValue = AmpFactorToDB(lLinTemp);

    return lLogValue;
}

//算出播放器音量大小的百分比
short VolumeLogToLin(LONG lLogValue)
{
    LONG lLinMin = DBToAmpFactor(AX_MIN_VOLUME);
    LONG lLinMax = DBToAmpFactor(AX_MAX_VOLUME);

    short nLinKnobValue = (short)( ((LONG) DBToAmpFactor(lLogValue) - lLinMin) *
        (MAX_VOLUME_RANGE - MIN_VOLUME_RANGE) / (lLinMax - lLinMin) + MIN_VOLUME_RANGE);

    return nLinKnobValue;
}

//m_Player为播放器控件

//取得模音量大小

int nVolume = VolumeLogToLin(m_Player.GetVolume());

//设置音量大小

m_Player.SetVolume(VolumeLinToLog(nVolume));

 

上一篇:Android 音乐播放


下一篇:pyqt5播放视频,flash