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 speaker volume set:"), _ L ("successful ")); <br/>}< br/> else <br/> {<br/> ceikonenv: infowinl (_ L ("phone speaker vol set err :"), lbuferr); <br/>}
Cr keys to control phone volume API provides buttons to control the volume of mobile phones during calls.
-Ktelephonyincallearvolume and ktelephonyincallloudspeakervolume Cr keys can be used to increase or decrease the phone volume during a call.
Sample Code
Header file:
# Include <telephonyinternalcrkeys_partner.h> // Cr keys to control phone volume <br/> # include <centralrepository. h> // crepository
From and ex
Link Library:
Centralrepository. Lib // crepository
Required capabilities
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;
The call volume of mobile phone headphones and speakers can be controlled by passing the "ktelephonyincallearvolume" and "telephonyincallloudspeakervolume" parameters through the get () method and set () method of crepository.
//To create a CRepository object for accessing Phone Volume repository:iRepository = CRepository::NewL(KCRUidCallHandling);
Run the following code to obtain the headset volume during a call:
TBuf<3> lBufVol;TInt lVol;User::LeaveIfError(iRepository->Get(KTelephonyIncallEarVolume,lVol));lBufVol.AppendNum(lVol);CEikonEnv::InfoWinL(_L("Phone Incall Ear Volume:"),lBufVol);
Run the following code to obtain the speaker volume during a call:
TBuf<3> lBufVol;TInt lVol;User::LeaveIfError(iRepository->Get(KTelephonyIncallLoudspeakerVolume, lVol));lBufVol.AppendNum(lVol);CEikonEnv::InfoWinL(_L("Phone Incall Loud Speaker Volume:"),lBufVol);
The following code sets the volume of the headset or speaker: