Android左右声道音频文件测试

测试左右声道,其实主要步骤是制作一个 含有左右声道的音频文件。

private MediaPlayer mMedieplayer;

       Button mButton = (Button)findViewById(R.id.soundtrack_but);
       AudioManager mAudioManager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);

       int audio_max = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
       int audio_cur = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
       mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, audio_max, AudioManager.FLAG_PLAY_SOUND);
       
       
       mButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
         // TODO Auto-generated method stub
            mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC,
            audio_max, AudioManager.FLAG_PLAY_SOUND);

          try {
             mMedieplayer= MediaPlayer.create(this, R.raw.test);//主要是这个音频文件的制作
             mMedieplayer.start();
          } catch (IllegalArgumentException e) {
           e.printStackTrace();
          } catch (IllegalStateException e) {
           e.printStackTrace();

          }
          mMedieplayer
            .setOnCompletionListener(new OnCompletionListener() {
             @Override
             public void onCompletion(MediaPlayer mp) {
              mp.stop();
              mp.release();
              mp = null;
             }
            });
        }
       });
       mButton.performClick(); 

你可能感兴趣的:(android,左右声道测试)