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

相关推荐
10km22 分钟前
java:Apache Commons Configuration2占位符解析异常的正确解法:${prefix:name:-default}
java·apache·configuration2·变量插值·interpolation
customer0823 分钟前
【开源免费】基于SpringBoot+Vue.JS个人博客系统(JAVA毕业设计)
java·vue.js·spring boot·后端·开源
灰色人生qwer30 分钟前
SpringBoot 项目配置日志输出
java·spring boot·后端
2301_7930698240 分钟前
Spring Boot +SQL项目优化策略,GraphQL和SQL 区别,Spring JDBC 等原理辨析(万字长文+代码)
java·数据库·spring boot·sql·jdbc·orm
阿华的代码王国1 小时前
【从0做项目】Java搜索引擎(6)& 正则表达式鲨疯了&优化正文解析
java·后端·搜索引擎·正则表达式·java项目·从0到1做项目
服务端相声演员1 小时前
Oracle JDK、Open JDK zulu下载地址
java·开发语言
是姜姜啊!1 小时前
java连接redis
java·redis
hhw1991121 小时前
spring boot知识点5
java·数据库·spring boot
EQUINOX11 小时前
lab4 CSAPP:Cachelab
java·后端·spring
customer081 小时前
【开源免费】基于SpringBoot+Vue.JS打卡健康评测系统(JAVA毕业设计)
java·vue.js·spring boot·后端·开源