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

相关推荐
全栈凯哥21 分钟前
16.Spring Boot 国际化完全指南
java·spring boot·后端
M1A127 分钟前
Java集合框架深度解析:LinkedList vs ArrayList 的对决
java·后端
Top`31 分钟前
Java 泛型 (Generics)
java·开发语言·windows
爱吃土豆的马铃薯ㅤㅤㅤㅤㅤㅤㅤㅤㅤ1 小时前
如何使用Java WebSocket API实现客户端和服务器端的通信?
java·开发语言·websocket
是小崔啊1 小时前
tomcat源码02 - 理解Tomcat架构设计
java·tomcat
小袁拒绝摆烂1 小时前
SQL开窗函数
android·sql·性能优化
没有bug.的程序员1 小时前
JAVA面试宝典 -《安全攻防:从 SQL 注入到 JWT 鉴权》
java·安全·面试
栈溢出了1 小时前
MyBatis实现分页查询-苍穹外卖笔记
java·笔记·mybatis
morningcat20182 小时前
java17 gc笔记
java·jvm·笔记
2 小时前
Unity开发中常用的洗牌算法
java·算法·unity·游戏引擎·游戏开发