Move away from Promise-based getMp3MediaRecorder API
elsmr opened this issue · comments
Ideally usage should be as simple as importing the Mp3MediaRecorder class directly instead of the getMp3MediaRecorder Promise API. The choice to preload the worker can be left to the user, so they have 2 options to use the library.
Option 1
The worker is initialized in the constructor. There might be a longer delay between the user calling .start()
and the 'start' event being dispatched because of the time it takes to set up the worker.
import { Mp3MediaRecorder } from 'mp3-mediarecorder';
const recorder = new Mp3MediaRecorder(stream);
recorder.start();
Option 2
Here the worker is initialized by the initWorker Promise. After that there will be (almost) no delay between calling .start()
and the 'start' event dispatching. Similar to the current getMp3MediaRecorder API.
import { Mp3MediaRecorder, initWorker } from 'mp3-mediarecorder';
initWorker().then(() => {
const recorder = new Mp3MediaRecorder(stream);
recorder.start();
});
🎉 This issue has been resolved in version 4.0.0 🎉
The release is available on:
Your semantic-release bot 📦🚀