android audio 相机按键音:(二)加载与修改

相机按键音资源,加载文件路径:

frameworks/av/services/camera/libcameraservice/CameraService.cpp

按键音,加载函数:

void CameraService::loadSoundLocked(sound_kind kind) {

ATRACE_CALL();

LOG1("CameraService::loadSoundLocked ref=%d", mSoundRef);

if (SOUND_SHUTTER == kind && mSoundPlayer[SOUND_SHUTTER] == NULL) {

// 拍照按键音资源加载

mSoundPlayer[SOUND_SHUTTER] = newMediaPlayer("/product/media/audio/ui/camera_click.ogg");

if (mSoundPlayer[SOUND_SHUTTER] == nullptr) {

mSoundPlayer[SOUND_SHUTTER] = newMediaPlayer("/system/media/audio/ui/camera_click.ogg");

}

} else if (SOUND_RECORDING_START == kind && mSoundPlayer[SOUND_RECORDING_START] == NULL) {

// 录像启动按键音资源加载

mSoundPlayer[SOUND_RECORDING_START] = newMediaPlayer("/product/media/audio/ui/VideoRecord.ogg");

if (mSoundPlayer[SOUND_RECORDING_START] == nullptr) {

mSoundPlayer[SOUND_RECORDING_START] = newMediaPlayer("/system/media/audio/ui/VideoRecord.ogg");

}

} else if (SOUND_RECORDING_STOP == kind && mSoundPlayer[SOUND_RECORDING_STOP] == NULL) {

// 录像停止按键音资源加载

mSoundPlayer[SOUND_RECORDING_STOP] = newMediaPlayer("/product/media/audio/ui/VideoStop.ogg");

if (mSoundPlayer[SOUND_RECORDING_STOP] == nullptr) {

mSoundPlayer[SOUND_RECORDING_STOP] = newMediaPlayer("/system/media/audio/ui/VideoStop.ogg");

}

}

}

用户可以自定义修改,按键音:

替换按键音资源,直接替换camera_click.ogg,VideoRecord.ogg,VideoStop.ogg。

禁止按键音,可以直接删除资源或在资源加载过程进行禁止修改。

声音资源路径:

frameworks\base\data\sounds\effects\ogg

camera_click.ogg

camera_click_48k.ogg

adb查看设备,声音资源路径:

a71x:/system/media/audio/ui $ ls -al camera*

-rw-r--r-- 1 root root 8703 2008-12-31 23:00 camera_click.ogg

-rw-r--r-- 1 root root 9376 2008-12-31 23:00 camera_focus.ogg

相关推荐
组合缺一2 分钟前
Java 版 Claude Code CLI 来了!(国产开源项目)Solon Code CLI 发布
java·ai·开源·llm·solon·cli·claudecode
systeminof14 分钟前
从静态到实时对抗:首例安卓Runtime AI病毒解析
android·人工智能
javaIsGood_1 小时前
Java基础面试题
java·开发语言
indexsunny1 小时前
互联网大厂Java求职面试实战:基于电商场景的技术问答及解析
java·spring boot·redis·kafka·security·microservices·面试指导
福大大架构师每日一题1 小时前
ComfyUI v0.14.2 发布:修复 Gemini/Nano banana 节点空白图像问题,全新 MIME 匹配机制登场
android·comfyui
Forget_85502 小时前
RHEL——LVS模式
java·开发语言·lvs
渣瓦攻城狮2 小时前
互联网大厂Java面试:从数据库连接池到分布式缓存及微服务
java·redis·spring cloud·微服务·hikaricp·数据库连接池·分布式缓存
罗超驿2 小时前
13.1 万字长文,深入解析--抽象类和接口
java·开发语言
fengci.2 小时前
ctfshow大牛杯
android
A懿轩A2 小时前
【Java 基础编程】Java 面向对象进阶:static/final、抽象类、接口、单例模式
java·开发语言·单例模式