目前市面上的所有移动终端几乎都有camera 应用,但Android .html">Android 原生系统在静音模式下拍照是没有声音的,大部分国家的终端都有法规限制,如防止偷*拍 ,不管什么模式下拍照都应该发出快门音,针对此问题只要修改Android .html">Android 原生camera service.cpp中playSound函数即可,

android 4.0.3声音分类

typedef enum {    AUDIO_STREAM_DEFAULT          = -1,    AUDIO_STREAM_VOICE_CALL       = 0,    AUDIO_STREAM_SYSTEM           = 1,    AUDIO_STREAM_RING             = 2,    AUDIO_STREAM_MUSIC            = 3,    AUDIO_STREAM_ALARM            = 4,    AUDIO_STREAM_NOTIFICATION     = 5,    AUDIO_STREAM_BLUETOOTH_SCO    = 6,    AUDIO_STREAM_ENFORCED_AUDIBLE = 7, /* Sounds that cannot be muted byuser and must be routed to speaker */    AUDIO_STREAM_DTMF             = 8,    AUDIO_STREAM_TTS              = 9,        AUDIO_STREAM_FM               = 10,    AUDIO_STREAM_MATV             = 11,    AUDIO_STREAM_BOOT             = 12, //only used for bootanimationand output from speaker and headset    AUDIO_STREAM_CNT,    AUDIO_STREAM_MAX              = AUDIO_STREAM_CNT - 1,} audio_stream_type_t;

修改后的方法如下:

void cameraService::playSound(sound_kind kind) {    LOG1("playSound(%d)", kind);    Mutex::Autolock lock(mSoundLock);    sp<MediaPlayer> player = mSoundPlayer[kind];    if (player != 0) {        // do not play the sound if stream volume is 0        // (typically because ringer mode is silent).        int index;        AudioSystem::getStreamVolumeIndex(AUDIO_STREAM_ENFORCED_AUDIBLE, &index);        if (index != 0) {              AudioSystem::setStreamVolumeIndex(AUDIO_STREAM_ENFORCED_AUDIBLE,index);            player->seekTo(0);            player->start();        } else {                AudioSystem::setStreamVolumeIndex(AUDIO_STREAM_ENFORCED_AUDIBLE,7);                        player->seekTo(0);                        player->start();                        usleep(300000);                        AudioSystem::setStreamVolumeIndex(AUDIO_STREAM_ENFORCED_AUDIBLE,0);        }    }} 

更多相关文章

  1. Android(安卓)Add-ons
  2. Android(安卓)设置声音时出现按键音
  3. android 调用摄像头
  4. 使用Javascript判断浏览器终端设备(PC、IOS(iphone)、Android)
  5. 无法安装ADT(无法访问https://dl-ssl.google.com/android/eclipse
  6. Android之拍照
  7. 为什么说Android令人沮丧!?
  8. js判断手机是Android还是iOS
  9. 【Android车载系统 News | Tech 5】车载设计开发

随机推荐

  1. Android 系统framework 概述
  2. Android上的Notification
  3. Logger详解(一)
  4. Android Studio镜像设置
  5. 【android】android短信数据库表
  6. Android快速集成框架:MVP+Dagger+主流框架
  7. Android创建桌面快捷方式
  8. Android软件开发常用系统控件(一) TextView
  9. 第十四周实验报告:实验四 Android程序设计
  10. listview android:cacheColorHint,listSe