zoukankan      html  css  js  c++  java
  • Android多媒体分析(六)对AudioManager的一点补充

    Android 各种音量的获取和设置
    通过程序获取android系统手机的铃声和音量。同样,设置铃声和音量的方法也很简单!

    AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    //通话音量
          int max = am.getStreamMaxVolume( AudioManager.STREAM_VOICE_CALL );
          int current = am.getStreamVolume( AudioManager.STREAM_VOICE_CALL );
          Log.d(”VIOCE_CALL”, “max : ” + max + ” current : ” + current);
    //系统音量
          max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_SYSTEM ); 
    current = mAudioManager.getStreamVolume( AudioManager.STREAM_SYSTEM ); 
          Log.d(”SYSTEM”, “max : ” + max + ” current : ” + current);
    //铃声音量
          max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_RING );
          current = mAudioManager.getStreamVolume( AudioManager.STREAM_RING );
          Log.d(”RING”, “max : ” + max + ” current : ” + current);
    //音乐音量
          max = mAudioManager.getStreamMaxVolume( AudioManager.STREAM_MUSIC );
          current = mAudioManager.getStreamVolume( AudioManager.STREAM_MUSIC );
          Log.d(”MUSIC”, “max : ” + max + ” current : ” + current);
    //提示声音音量
          max = am.getStreamMaxVolume( AudioManager.STREAM_ALARM );
          current = sm.getStreamVolume( AudioManager.STREAM_ALARM );
          Log.d(”ALARM”, “max : ” + max + ” current : ” + current);
    


     

    设置音量的方法也很简单,AudioManager提供了方法:
    public void setStreamVolume(int streamType, int index, int flags)
    其中 streamType 有内置的常量,可以在AudioManager里面查到相关的定义。

  • 相关阅读:
    css篇-less,scss 用calc问题
    工具篇-Mac上搭建本地svn服务器以及使用Cornerstone进行本地版本控制
    小程序篇-开发工具报错
    js篇-json字符串与json对象相互转化
    小程序篇- data 数据绑定
    RN-android 打包后,部分图片不显示
    asxios--form data提交,setcookie
    RN-系列
    纯css 实现横向滚动条--移动端
    Oralce给字段追加字符,以及oracle 给字段替换字符
  • 原文地址:https://www.cnblogs.com/wuyida/p/6300654.html
Copyright © 2011-2022 走看看