欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 科技 > IT业 > android audio 相机按键音:(二)加载与修改

android audio 相机按键音:(二)加载与修改

2025/4/20 15:21:40 来源:https://blog.csdn.net/xuann/article/details/140590404  浏览:    关键词: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

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词