Jazz-Soft.net

We make it sound!

Home » Documentation » JZZ.js » JZZ.gui.Player

JZZ.gui.Player

MIDI Player

MIDI Player GUI for browser.

Construction

JZZ.gui.Player(parent) or JZZ.gui.Player(x, y) - create a new MIDI Player widget; works with or without the new keyword.

parent - parent; can be a DOM object itself, or its id as string.

x, y - coordinates of the top-left corner; if parent is not found or undefined, the widget is created moveable and floating at the specified position.

load()

player.load(smf) - load MIDI data and enable the playback buttons.

smf is a JZZ.MIDI.SMF object.

play()

player.play() - start or resume playing if stopped or paused.

stop()

player.stop() - stop and skip to the beginning if playing or paused.

pause()

player.pause(value) - pause / resume.

value - if true - pause; if false - resume; if undefined - toggle between paused / resumed states.

loop()

player.loop(value) - set / unset the loop.

value - if integer - set the loop to value; if true - set the loop to infinity; if false - unset the loop; if undefined - toggle between infinity / unset loop.

duration()

player.duration() - return the MIDI file duration in MIDI ticks.

position()

player.position() - return the current MIDI file position in MIDI ticks.

jump()

player.jump(pos) - jump to specified position.

pos - position in MIDI ticks.

connect()

player.connect(out) - connect an output port or handler that will receive the playback.

out - an output port or a handler function; see MidiIn.connect().

When there is a manually connected port or handler, the MIDI select button is disabled.

disconnect()

player.disconnect(out) - disconnect an output port or handler.

out - an output port or a handler function; see MidiIn.disconnect().

When there is no manually connected ports or handlers, the MIDI select button becomes enabled.

Example

<script src="JZZ.js"></script>
<script src="JZZ.gui.Player.js"></script>
<script src="JZZ.midi.SMF.js"></script>

<div id=player></div>

<script><!--
  var player = new JZZ.gui.Player('player');
  var data = ... // read MIDI file as string
  player.load(new JZZ.MIDI.SMF(data));
  player.loop(5);
  player.play();
--></script>

See also