grimmdude / MidiPlayerJS

♬ MIDI parser & player engine for browser or Node. As a parser converts MIDI events into JSON. Works well with single or multitrack MIDI files.
https://grimmdude.com/MidiPlayerJS/
MIT License
359 stars 52 forks source link

Typescript counterpart #12

Closed tjvg91 closed 6 years ago

tjvg91 commented 6 years ago

Is there a typescript counterpart for this? I plan to embed this in an Angular 4 project but I get this error:

ReferenceError: require is not defined

grimmdude commented 6 years ago

I'm not too familiar with TypeScript. @TimMensch do you have any insight to this?

gciluffo commented 6 years ago

@tjvg91 If your using typescript you can just do import * as MidiPlayer from 'midi-player-js';

tjvg91 commented 6 years ago

thanks @gciluffo but I get this error this time: Error: Cannot find module 'fs'

TimMensch commented 6 years ago

Module 'fs' doesn't exist on the browser. You can't use the file API in the browser.

tjvg91 commented 6 years ago

How can i do so? @TimMensch

TimMensch commented 6 years ago

Please don't ask questions until you have done a minimum of research yourself. The bare minimum in this case is reading the docs:

http://grimmdude.com/MidiPlayerJS/docs/Player.html#loadFile

See how it says loadFile() is Node.js only? That means it won't work in the browser. Look at the other options and choose one.