TInt lVol = 6;<br />TInt lErr = iRepository->Set(KTelephonyIncallEarVolume,lVol);<br />TBuf<10> lBufErr;<br />lBufErr.AppendNum(lErr);<br />if ( lErr == KErrNone )<br /> {<br /> CEikonEnv::InfoWinL(_L("Phone Ear Volume Set:"),_L("Successful"));<br /> }<br />else<br /> {<br /> CEikonEnv::InfoWinL(_L("Phone Ear Volume Set Err:"),lBufErr);<br /> }</p><p>lBufErr.Zero();<br />lErr = iRepository->Set(KTelephonyIncallLoudspeakerVolume,lVol);<br />lBufErr.AppendNum(lErr);</p><p>if ( lErr == KErrNone )<br /> {<br /> CEikonEnv::InfoWinL(_L("Phone Loud Speaker Volume Set:"),_L("Successful"));<br /> }<br />else<br /> {<br /> CEikonEnv::InfoWinL(_L("Phone Loud Speaker Vol Set Err:"),lBufErr);<br /> }
CR keys To Control Phone Volume API提供按鍵可以在通話時控制手機音量。
- KTelephonyIncallEarVolume和KTelephonyIncallLoudspeakerVolume CR keys可以用來增加或減少通話時手機音量。
範例程式碼
標頭檔:
#include <telephonyinternalcrkeys_partner.h> //CR Keys To Control Phone Volume<br />#include <centralrepository.h> //CRepository
FROM And EX
連結庫:
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);
下列代碼可以設定耳機或擴音器的音量: