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();
            }
        }

  • 相关阅读:
    JavaWeb 输出九九乘法表,三角形,菱形
    模拟ATM机将输入的数据插入数据库
    JDBC连接数据库
    执行动态语句
    python深拷贝和浅拷贝
    redis数据库操作
    pymysql数据库操作
    linux 从Python 2.7升级至Python3.6.1
    模块---常用模块
    模块---安装模块
  • 原文地址:https://www.cnblogs.com/highfly2012/p/3056180.html
Copyright © 2011-2022 走看看