我正在开发一款允许用户快速点击并忘记快照的应用程序。大多数应用程序都已完成,除了相机以我想要的方式工作。现在我的相机正在工作,但我似乎找不到禁用快门声音的方法,也找不到禁用显示预览的方法。我能够用控件覆盖预览,但我宁愿尽可能不显示它。
总而言之,这些是我在使用内置相机控件时想要禁用的项目。
- 快门声
- 相机屏幕显示
- PictureTaken 上的图片预览
有谁知道可以为我指明正确方向的资源,我将不胜感激。我一直在关注来自 this sample 的 CommonsWare 示例相当接近。
谢谢。
最佳答案
这实际上是手机的 build.prop 中的一个属性。我不确定是否有可能改变这一点。除非你完全覆盖它并使用你自己的相机代码。尽你所能使用 SDK 中提供的内容。
看看这个:
CameraService.cpp . . .
CameraService::Client::Client(const sp<CameraService>& cameraService,
const sp<ICameraClient>& cameraClient,
const sp<CameraHardwareInterface>& hardware,
int cameraId, int cameraFacing, int clientPid) {
mPreviewCallbackFlag = FRAME_CALLBACK_FLAG_NOOP;
mOrientation = getOrientation(0, mCameraFacing == CAMERA_FACING_FRONT);
mOrientationChanged = false;
cameraService->setCameraBusy(cameraId);
cameraService->loadSound();
LOG1("Client::Client X (pid %d)", callingPid)
}
void CameraService::loadSound() {
Mutex::Autolock lock(mSoundLock);
LOG1("CameraService::loadSound ref=%d", mSoundRef);
if (mSoundRef++) return;
mSoundPlayer[SOUND_SHUTTER] = newMediaPlayer("/system/media/audio/ui/camera_click.ogg");
mSoundPlayer[SOUND_RECORDING] = newMediaPlayer("/system/media/audio/ui/VideoRecord.ogg");
}
可以注意到,点击声音是在没有您的交互的情况下启动的。
这是 Gingerbread 源代码中使用的服务。
他们不允许这样做的原因是因为在某些国家这是非法的。实现您想要的唯一方法是拥有自定义 ROM。
更新
如果这里说的是:http://androidforums.com/t-mobile-g1/6371-camera-shutter-sound-effect-off.html
仍然适用,然后您可以编写一个计时器来关闭声音(静音模式)几秒钟,然后在每次拍照时将其重新打开。
关于Android Camera.takePicture - 可以禁用快门声音和预览表面吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9106939/