android audio 相机按键音:(二)加载与修改 [复制链接]
发表于 2026-4-27 11:10:20 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
相机按键音资源,加载文件路径:
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

可参考:android audio 相机按键音:(一)资源加载与更换-CSDN博客

回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表