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. android audio 相机按键:()修改

    2024-07-21 23:40:05       20 阅读
  2. android audio 相机按键:(一)资源替换

    2024-07-21 23:40:05       16 阅读
  3. Threejs字体FontLoaderTTFLoader

    2024-07-21 23:40:05       27 阅读
  4. 编程思想:预

    2024-07-21 23:40:05       23 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-21 23:40:05       52 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-21 23:40:05       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-21 23:40:05       45 阅读
  4. Python语言-面向对象

    2024-07-21 23:40:05       55 阅读

热门阅读

  1. 数字转换(树形DP)

    2024-07-21 23:40:05       18 阅读
  2. python 爬虫技术 第03节 基础复习 控制结构

    2024-07-21 23:40:05       17 阅读
  3. Python 模块导入方式

    2024-07-21 23:40:05       19 阅读
  4. 基于最新版的flutter pointycastle: ^3.9.1的AES加密

    2024-07-21 23:40:05       15 阅读
  5. Shiro-550反序列化漏洞

    2024-07-21 23:40:05       15 阅读
  6. Kotlin单例、数据类、静态

    2024-07-21 23:40:05       18 阅读
  7. CSP-J模拟赛day1

    2024-07-21 23:40:05       19 阅读