• Android 播放声音


        public static void PlayAlarmRing(Context mContext) {
            Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
            try {
                MediaPlayer mMediaPlayer = new MediaPlayer();
                mMediaPlayer.setDataSource(mContext, alert);
                final AudioManager audioManager = (AudioManager) mContext
                        .getSystemService(Context.AUDIO_SERVICE);
                if (audioManager.getStreamVolume(AudioManager.STREAM_ALARM) != 0) {
                    mMediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM);
                    mMediaPlayer.setLooping(false);
                    mMediaPlayer.prepare();
                    mMediaPlayer.start();
                }
            } catch (IllegalStateException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    

      无视手机的静音模式

  • 相关阅读:
    计算机基础(7)
    计算机基础(6)
    计算机基础(5)
    计算机基础(4)
    计算机基础(3)
    计算机基础(2)
    计算机基础(1)
    数组、函数
    js基础知识
    随笔3
  • 原文地址:https://www.cnblogs.com/zhou-guobao/p/4674163.html
Copyright © 2020-2023  润新知