title: Android - how to play a midi file data to external midi keyboard
body: <p>Following up (or should have been preceding) <a href="https://stackoverflow.com/questions/71881037/android-can-i-direct-midi-output-of-mediaplayer-to-bluetooth">my last post</a>, I am now wondering if I am on the wrong path.</p>
  <p>I want to play midi file <strong>data</strong> (not audio) to an external device, such as a midi enabled keyboard, and have the midi data play the keyboard.</p>
  <p>As per my last post, I have:</p>
  <pre><code>MediaPlayer mediaPlayer;
  
  String music = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).getAbsolutePath();
  mediaPlayer = MediaPlayer.create(MainActivity.this, Uri.parse(music + &quot;/test.mid&quot;));
  mediaPlayer.start();
  </code></pre>
  <p>When I run this, it just play the midi file as audio.</p>
  <p>Later, the next part is sending this out (hopefully) by Bluetooth, ie code sometime like form the suggestion from my last post:</p>
  <pre><code>AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
  AudioDeviceInfo[] devices = audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS);
  
  for (AudioDeviceInfo device : devices) {
      int type = device.getType();
      if (device.getType() == AudioDeviceInfo.TYPE_BLE_HEADSET ) {
          mediaPlayer.setPreferredDevice(device);
          break;
      }
  }
  </code></pre>
  <p>However, is the above going to midi <strong>data</strong>, or just the generated audio? Can <code>MediaPlayerMediaPlayer</code> be used for this, or do I need to use something completely different such as <a href="https://www.geeksforgeeks.org/java-midi/" rel="nofollow noreferrer">java-midi</a> or the <a href="https://github.com/philburk/android-midisuite" rel="nofollow noreferrer">MidiManager</a> as used in these examples.</p>
  <p>I have not got any Bluetooth midi receiver device yet (ie to play into the keyboard), as I do not want to purchase something like this, <a href="https://www.storedj.com.au/yamaha-md-bt01-bluetooth-wireless-midi-adaptor?gclid=Cj0KCQjwr-SSBhC9ARIsANhzu14MQwO3PwHV2unaKk9Lo11Gs7fgiR-M_rSnlLWznODlqHPEi29fpFQaAjEsEALw_wcB" rel="nofollow noreferrer">for example this, though it only claim to support iOS, but isn't Bluetooth universal?</a>, At any rate, that is a separate topic, this is just about actually playing out the midi data</p>
  <p>I only ever want to replay a file, I never want to actually generate the midi events, so was hoping something simpler like <code>MediaPlayer</code> would do what I am after, but is this correct?</p>