midi-player

July 9, 2022 ยท View on GitHub

MIDI player element. See also the @magenta/music/core/player docs.

The element supports styling using the CSS ::part syntax (see the list of shadow parts below). For example:

midi-player::part(control-panel) {
     background: aquamarine;
     border-radius: 0px;
}

Attributes

AttributeDescription
visualizerA selector matching midi-visualizer elements to bind to this player

Properties

PropertyAttributeTypeDescription
currentTimenumberCurrent playback position in seconds
durationnumberContent duration in seconds
looploopbooleanIndicates whether the player should loop
noteSequenceINoteSequence | nullMagenta note sequence object representing the currently loaded content
playingbooleanIndicates whether the player is currently playing
soundFontsound-fontstring | nullMagenta SoundFont URL, an empty string to use the default SoundFont, or null to use a simple oscillator synth
srcsrcstring | nullMIDI file URL

Methods

MethodType
addVisualizer(visualizer: VisualizerElement): void
reload(): void
removeVisualizer(visualizer: VisualizerElement): void
start(): void
stop(): void

Events

EventTypeDescription
loadThe content is loaded and ready to play
loopThe player has automatically restarted playback after reaching the end
noteCustomEvent<{ note: INote; }>A note starts
startThe player has started playing
stopCustomEvent<{ finished: boolean; }>The player has stopped playing

CSS Shadow Parts

PartDescription
control-panel<div> containing all the controls
current-timeElapsed time
loading-overlayOverlay with shimmer animation
play-buttonPlay button
seek-bar<input type="range"> showing playback position
timeNumeric time indicator
total-timeTotal duration