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

相关推荐
好奇的菜鸟1 小时前
如何在IntelliJ IDEA中设置数据库连接全局共享
java·数据库·intellij-idea
哲科软件2 小时前
跨平台开发的抉择:Flutter vs 原生安卓(Kotlin)的优劣对比与选型建议
android·flutter·kotlin
DuelCode2 小时前
Windows VMWare Centos Docker部署Springboot 应用实现文件上传返回文件http链接
java·spring boot·mysql·nginx·docker·centos·mybatis
优创学社22 小时前
基于springboot的社区生鲜团购系统
java·spring boot·后端
幽络源小助理2 小时前
SpringBoot基于Mysql的商业辅助决策系统设计与实现
java·vue.js·spring boot·后端·mysql·spring
猴哥源码2 小时前
基于Java+springboot 的车险理赔信息管理系统
java·spring boot
YuTaoShao3 小时前
【LeetCode 热题 100】48. 旋转图像——转置+水平翻转
java·算法·leetcode·职场和发展
Dcs3 小时前
超强推理不止“大”——手把手教你部署 Mistral Small 3.2 24B 大模型
java
东阳马生架构3 小时前
订单初版—1.分布式订单系统的简要设计文档
java
Code blocks4 小时前
使用Jenkins完成springboot项目快速更新
java·运维·spring boot·后端·jenkins