Prefab MidiListPlayer

MidiListPlayer is a Prefab, available with the Pro version, able to play Midi music from a list of Midi from your MPTK database in Unity.

Furthermore, you can play part of a Midi files, overlap, loop.

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

Inspector parameters

Overlap time in milliseconds of overlap between two Midi. The end of the current Midi gently overlaps the start of the next Midi.

Play On Start if checked, start playing when your application start.

Loop on the List if checked, restart playing automatically at the first when the end of the Midi list is reached.

Add a new entry to the list
Remove the selected entry
Move Up the selected entry
Move Down the selected entry

When running:

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 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"); else midiListPlayer = fp; } // This method is fired from button public void Next() { midiListPlayer.MPTK_Next(); }