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 && mSoundPlayerSOUND_SHUTTER == NULL) {

// 拍照按键音资源加载

mSoundPlayerSOUND_SHUTTER = newMediaPlayer("/product/media/audio/ui/camera_click.ogg");

if (mSoundPlayerSOUND_SHUTTER == nullptr) {

mSoundPlayerSOUND_SHUTTER = newMediaPlayer("/system/media/audio/ui/camera_click.ogg");

}

} else if (SOUND_RECORDING_START == kind && mSoundPlayerSOUND_RECORDING_START == NULL) {

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

mSoundPlayerSOUND_RECORDING_START = newMediaPlayer("/product/media/audio/ui/VideoRecord.ogg");

if (mSoundPlayerSOUND_RECORDING_START == nullptr) {

mSoundPlayerSOUND_RECORDING_START = newMediaPlayer("/system/media/audio/ui/VideoRecord.ogg");

}

} else if (SOUND_RECORDING_STOP == kind && mSoundPlayerSOUND_RECORDING_STOP == NULL) {

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

mSoundPlayerSOUND_RECORDING_STOP = newMediaPlayer("/product/media/audio/ui/VideoStop.ogg");

if (mSoundPlayerSOUND_RECORDING_STOP == nullptr) {

mSoundPlayerSOUND_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 小时前
leetcode3751 范围内总波动值I
java·数据结构·c++·算法·leetcode
闪电悠米2 小时前
黑马点评-Redisson-01_why_redisson
java·服务器·网络·数据库·缓存·wpf
星轨zb2 小时前
LangChain4j 集成 Spring Boot:会话记忆 NPE 的根源与 ChatMemoryProvider 正确配置
java·spring boot·后端·langchain4j
JAVA9652 小时前
JAVA面试-并发篇 05-并发包AQS队列实现原理是什么
java·开发语言·面试
JAVA面经实录9172 小时前
RocketMQ全套学习知识手册
java·kafka·rabbitmq·rocketmq
phltxy2 小时前
Spring AI 从提示词到多模态
java·人工智能·spring
Halo_tjn3 小时前
反射与设计模式1
java·开发语言·算法
神仙别闹3 小时前
基于Python + SQL server 实现(GUI)原神圣遗物管理与角色数值模拟系统
java·数据库·python
是有头发的程序猿3 小时前
电商自动化实战:淘宝/天猫item_get商品详情API全量采集教程(Python源码)
java·python·自动化