zoukankan      html  css  js  c++  java
  • 播放系统默认提示音

        static MediaPlayer mMediaPlayer;
        public static void play() {
            try {
                Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
                mMediaPlayer = new MediaPlayer();
                mMediaPlayer.setDataSource(Registry.context2, alert);
                final AudioManager audioManager = (AudioManager) Registry.context2.getSystemService(Context.AUDIO_SERVICE);
                if (audioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION) != 0) {
                    mMediaPlayer.setAudioStreamType(AudioManager.STREAM_NOTIFICATION);
                    mMediaPlayer.setLooping(false);
                    mMediaPlayer.prepare();
                    mMediaPlayer.start();
                    mMediaPlayer.setOnCompletionListener(new OnCompletionListener() {                    
                        @Override
                        public void onCompletion(MediaPlayer mp) {
                            mp.release();
                        }
                    });
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

  • 相关阅读:
    自我介绍
    自动生成小学生四则运算(C语言)
    黄金点游戏
    7/5linux命令(整理中)
    第二章内容及作业
    第三章笔记
    第一章作业
    第一阶段笔记整理7.23
    第三章课后作业
    7/6linux命令
  • 原文地址:https://www.cnblogs.com/highfly2012/p/3056180.html
Copyright © 2011-2022 走看看