Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

怎样在使用摄像头拍照时添加一个快门声

From Wiki
Jump to: navigation, search
Article Metadata

文章
huwell 在 30 Jun 2007 创建
最后由 hamishwillee 在 30 May 2013 编辑
  • 原因:

在一部60系列设备上, 我怎样可以在使用摄像头拍照的时候添加一个快门的 声音呢?


  • 说明:

使用CAknKeySoundSystem类将会在摄像头捕捉籣面的 时候播放声音方面是一个很有效的方法。下面的代码 演示了如何在你的应用程序中实现这个特性:

// myapp.h
 
#include <aknsoundsystem.h>
 
const TInt KSnapSoundId = 2;
 
class MyClass
 
{
 
...
 
private:
 
CAknKeySoundSystem* iCameraSound;
 
};
 
void MyClass::ConstructL()
{
 
...
 
iCameraSound =
 
static_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi())->KeySounds();
 
if (iCameraSound)
 
{
 
TRAPD(error, iCameraSound->AddAppSoundInfoListL(
 
R_CAMERA_SNAP_SOUND));
 
if ((error != KErrAlreadyExists) && (error != KErrNone))
 
{
 
User::LeaveIfError(error);
 
}
}
}
 
void MyClass::PlaySnapSound()
{
iCameraSound->PlaySound(KSnapSoundId);
}


在你的.RSS资源文件中添加下面的代码

#define KcameraSoundFile
 
"Z:\\system\\sounds\\digital\\Camera1a_2_8kHz.wav"
 
#define KSnapSoundId 2
 
RESOURCE AVKON_SOUND_INFO_LIST r_camera_snap_sound
 
{
 
list =
 
{
 
AVKON_SOUND_INFO
 
{
 
sid = KSnapSoundId;
 
priority = 45;
 
preference = EAknAudioPrefCamera; // defined in avkon.hrh
 
file = KCameraSoundFile;
 
}
 
};
}
This page was last modified on 30 May 2013, at 04:37.
54 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.

×