chiptune2.js
chiptune2.js copied to clipboard
Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist.
Hey, trying to just play audio using:
async function initializePlayer() {
try {
while (typeof libopenmpt === 'undefined') {
await new Promise(resolve => setTimeout(resolve, 100));
}
var player = new ChiptuneJsPlayer(new ChiptuneJsConfig());
player.load('mymodule.mod', function (buffer) {
player.play(buffer);
});
} catch (error) {
console.error('Error initializing audio player:', error);
}
}
document.addEventListener('DOMContentLoaded', initializePlayer, { once: true });
get this error: index.html:1 Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist.
i think im including the correct files here:
<body>
<canvas id="gameCanvas" width="800" height="600"></canvas>
<script async src="./chiptune2.js/libopenmpt.js"></script>
<script src="./chiptune2.js/chiptune2.js"></script>
<script src="dist/bundle.js"></script>
</body>
Not sure if this is the issue here. The error message doesn't ring any bells for me (appears to be related to browser extensions?). I'm guessing you should wait until libopenmpt.onRuntimeInitialized gets called before you create an instance of ChiptuneJsPlayer. At least that's a potential source of problems. Waiting for libopenmpt to be be defined is not quite the same thing.