title: Record a sound from the phone (not the micro) with visualizer
body: <p>i try to record the sound from the phone. My goal is to launch a mediaplayer within my app,
  and my app added sounds on the mediaplayer sound (with soundpool ) . But here i can not capture
  the sound mediaplayer via my app . I have a file ( " audiofile ") which is created with a size , if i remember correctly, which is a function of the length to which i push on an icon , but when i play the file , i have nothing, no sound .</p>
  
  <p>I go through a visualizer because i understood that a recording by mediarecord or audiorecord only allows recording to any material only the microphone.</p>
  
  <p>Thanks</p>
  
  <pre><code>My code:
  
  public String fichierrecord="";
  private Button auriculaire=null;
  public boolean beginning=true;
  public Spinner selecti;
  public byte[]   mBytes=null;
  public ByteArrayOutputStream buffer;
  public     Visualizer v;
  
   @Override
       protected void onCreate(Bundle saveInstanceState) {
  
  super.onCreate(saveInstanceState);
  setContentView(R.layout.relalayou);
  selecti=(Spinner) findViewById(R.id.spinner13);
  auriculaire=(Button) findViewById(R.id.oreille);
  
  v=new Visualizer(0);
  
  
  
  
  buffer=new ByteArrayOutputStream();
  v.setEnabled(false);
  v.setCaptureSize(65536);
  Visualizer.OnDataCaptureListener c=new Visualizer.OnDataCaptureListener(){
  
      @Override
      public void onWaveFormDataCapture(Visualizer vv, byte[] wf, int sr){
  
          mBytes=  wf;
  
          if (wf.length&gt;-1){
  
              buffer.write(wf,0,wf.length);}
      }
      @Override
      public void onFftDataCapture(Visualizer vv, byte[] wf, int sr) {
      } };
  v.setDataCaptureListener(c,Visualizer.getMaxCaptureRate()/2,true,true);
  
  
      auriculaire.setOnClickListener(new View.OnClickListener(){
  
          @Override
          public void onClick(View arg) {
          if (beginning==true){
              Toast.makeText(MainActivity.this, "begin", Toast.LENGTH_LONG).show();
              v.setEnabled(true);  beginning=false;}
          else {v.setEnabled(false);
             try {
                 buffer.flush();
              } catch (IOException e) {
  
              }
              mBytes = buffer.toByteArray();
              try {
                  buffer.close();
              } catch (IOException e) {
  
              }
              v.release();
              File f = new File(Environment.getExternalStorageDirectory(), "audiofile.wav");
              FileOutputStream fos;
              try {
                  fos = new FileOutputStream(f);
                  fos.write(mBytes);
                  fos.flush();
                  fos.close();
              } catch (FileNotFoundException e) {
              } catch (IOException e) {
              }
              Toast.makeText(MainActivity.this, "end", Toast.LENGTH_LONG).show();
   }
  }List&lt;String&gt; exem=new ArrayList&lt;String&gt;();
      exem.add("notFile");
      exem.add("file");
      final ArrayAdapter&lt;String&gt; ada =new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1,exem);
      selecti.setAdapter(ada);
      selecti.setSelection(0);
      selectitonalite.setOnItemSelectedListener(new OnItemSelectedListener(){
          public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1,
                  int arg2, long arg3) {
  
  
                  if (selecti.getSelectedItemId()==){
                      Toast.makeText(MainActivity.this, "Select the audio file (.mp3,.mp4,.m4a,.wav,.3gp,.ogg,.mkv,.mid,.xmf,.mxmf,.rttt1,.rtx,.ota,.imy)" +
                              "on which you want to play", Toast.LENGTH_LONG).show();
                      Toast.makeText(MainActivity.this, "Select the audio file (.mp3,.mp4,.m4a,.wav,.3gp,.ogg,.mkv,.mid,.xmf,.mxmf,.rttt1,.rtx,.ota,.imy)" +
                              "on which you want to play", Toast.LENGTH_LONG).show();
                      File mPath = new File(Environment.getExternalStorageDirectory() + "//DIR//");
  
                      FileDialog fileDialog = new FileDialog(MainActivity.this, mPath);
                      fileDialog.setFileEndsWith(".mp3",".mp4",".m4a",".wav",".3gp",".ogg",".mkv",".mid",".xmf",".mxmf",".rttt1",".rtx",".ota",".imy");//,);
                      fileDialog.addFileListener(new FileDialog.FileSelectedListener() {
                          public void fileSelected(File file) {
  
                              File mmFichier = new File(fichierrecord);
                              if (mmFichier.exists()) {
                                  MediaPlayer m= new MediaPlayer();try{m.setDataSource(fichierrecord);m.prepare();}catch(IOException e){};
                               MediaPlayer.create(getApplicationContext(), Uri.fromFile(mmFichier));
                                  m.setVolume(1f,1f);
                                  m.start();
                              file.toString());
                          }}
                      });
                      fileDialog.showDialog();
                  }
  </code></pre>