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

  • 相关阅读:
    在你设计中可能用到的20个杂志 PSD 原型
    Gradify
    CamanJS – 提供各种图片处理的 JavaScript 库
    免费素材:包含 250+ 组件的 DO UI Kit
    24个很赞的 Node.js 免费教程和在线指南
    Dynamics.js
    Page Scroll Effects
    Slides
    15款加速 Web 开发的 JavaScript 框架
    Wee – 为现代 Web 开发打造的 CSS 脚手架
  • 原文地址:https://www.cnblogs.com/highfly2012/p/3056180.html
Copyright © 2011-2022 走看看