使用CAknKeySoundSystem类将会在摄像头捕捉籣面的 时候播放声音方面是一个很有效的方法。下面的代码 演示了如何在你的应用程序中实现这个特性: Code: // myapp.h #include const TInt KSnapSoundId = 2; class MyClass { ... private: CAknKeySoundSystem* iCameraSound; }; void MyClass::ConstructL() { ... iCameraSound = static_cast 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资源文件中添加下面的代码 Code: #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; } }; } |
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10294527/viewspace-126379/ ,如需转载,请注明出处,否则将追究法律责任。