×
Namespaces

Variants
Actions

手机音量API使用方法

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

代码示例
平台安全性
需要的签名: Self Signed
能力: WriteUserData

文章
翻译:
hoolee
最后由 hamishwillee 在 22 Dec 2011 编辑

Note.pngNote: 此API不是公开SDK的一部分,可以在SDK API Plug-in这里找到

Contents

目的

CR keys To Control Phone Volume API提供按键可以在通话时控制手机音量。

使用案例

- KTelephonyIncallEarVolume和KTelephonyIncallLoudspeakerVolume CR keys可以用来增加或减少通话时手机音量。

示例代码

头文件:

#include <telephonyinternalcrkeys_partner.h> //CR Keys To Control Phone Volume 
#include <centralrepository.h> //CRepository

链接库:

centralrepository.lib  //CRepository

所需能力

CAPABILITY    WriteUserData  //required for Setting the Volume:
//Telephony Call Handling Persistent Info API. 
//This API provides information related to call handling.
const TUid KCRUidCallHandling = {0x101F8784};
 
//Used by phone application, which contains the integer value
//of Incall in ear piece betweeen 1-10.
const TUint32 KTelephonyIncallEarVolume = 0x00000001;
 
//Used by phone application, which contains the integer value
//of Incall in Loud speaker betweeen 1-10.
const TUint32 KTelephonyIncallLoudspeakerVolume = 0x00000002;

手机耳机和扬声器的来电音量可以通过CRepository.的Get()方法和Set()方法传递"KTelephonyIncallEarVolume"和"TelephonyIncallLoudspeakerVolume"两个参数来控制。

//To create a CRepository object for accessing Phone Volume repository:
iRepository = CRepository::NewL(KCRUidCallHandling);

下列代码可以获得通话时耳机音量:

TBuf<3> lBufVol;
TInt lVol;
User::LeaveIfError(iRepository->Get(KTelephonyIncallEarVolume,lVol));
lBufVol.AppendNum(lVol);
CEikonEnv::InfoWinL(_L("Phone Incall Ear Volume:"),lBufVol);

下列代码可以获得通话时扬声器音量:

TBuf<3> lBufVol;
TInt lVol;
User::LeaveIfError(iRepository->Get(KTelephonyIncallLoudspeakerVolume, lVol));
lBufVol.AppendNum(lVol);
CEikonEnv::InfoWinL(_L("Phone Incall Loud Speaker Volume:"),lBufVol);

下列代码可以设置耳机或扬声器的音量:

TInt lVol = 6;
TInt lErr = iRepository->Set(KTelephonyIncallEarVolume,lVol);
TBuf<10> lBufErr;
lBufErr.AppendNum(lErr);
if ( lErr == KErrNone )
{
CEikonEnv::InfoWinL(_L("Phone Ear Volume Set:"),_L("Successful"));
}
else
{
CEikonEnv::InfoWinL(_L("Phone Ear Volume Set Err:"),lBufErr);
}
 
lBufErr.Zero();
lErr = iRepository->Set(KTelephonyIncallLoudspeakerVolume,lVol);
lBufErr.AppendNum(lErr);
 
if ( lErr == KErrNone )
{
CEikonEnv::InfoWinL(_L("Phone Loud Speaker Volume Set:"),_L("Successful"));
}
else
{
CEikonEnv::InfoWinL(_L("Phone Loud Speaker Vol Set Err:"),lBufErr);
}

示例代码下载

File:CRKeysCntrlPhVol.zip

File:Ear Lound switch speakers.zip

This page was last modified on 22 December 2011, at 07:59.
226 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×