控制手機音量的API使用方法

來源:互聯網
上載者:User

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);
下列代碼可以設定耳機或擴音器的音量:

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.