Prefab MidiListPlayer V2

MidiListPlayer is a Prefab able to play Midi music from a list of Midi from your MPTK DB.

  • This Prefab is available with MPTK Pro.
  • No line of script is necessary to use this Prefab.
  • But an API exists for a more complex integration in your application.
  • See an example with source code at the end of this page.

Add Midi to the list

Open the MidiDB in the Project Resources, select a Midi file, drag and drop on the list in the MidiListPlayer Inspector. If you don’t have the habit you could, before, lock the display of the inspector with the lock icon in the upper right corner.

Use the icon below the list to manage the list:

  • Select Midi to apply with the check or select All or select none.
  • Order to play the selected Midi with the buttons with an arrow.
  • Remove from the list with the button with an X.

Inspector parameters

When running:

  • Play On Start if checked, start playing when your application starts.
  • Loop on the List if checked, restart playing automatically at the first when the end of the Midi list is reached.
  • Play / Pause / Stop / Restart, change the current playing status.
  • Previous / Next load previous or next Midi in the MPTK Midi list.

Integrated MidiFilePLayer

In the MidiListPlayer, select MidiFilePlayer_1, the classical MidiFilePlayer Inspector is displayed.

See here for the description of each attributes and folders.

Integration of MidiListPlayer in your script

See TestMidiListPlayer.cs (not yet published) and events associated in the canvas gameobjects of TestListMidiPlay scene for the whole example.

using MidiPlayerTK;
// MPTK component able to play a Midi list. 
// This PreFab must be present in your scene.
/// </summary>
public MidiListPlayer midiListPlayer;
private void Start()
   if (!HelperDemo.CheckSFExists()) return;
 // Find the Midi external component 
    if (midiListPlayer == null)
       Debug.Log("No MidiListPlayer defined with the editor inspector, try to find one");
       MidiListPlayer fp = FindObjectOfType<MidiListPlayer>();
       if (fp == null)
          Debug.Log("Can't find a MidiListPlayer in the Hierarchy. No music will be played");
          midiListPlayer = fp;

// This method is fired from button
public void Next()