Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist. #47

Open
BorisMolch opened this issue Apr 30, 2023 · 1 comment

Comments

@BorisMolch
Copy link

BorisMolch commented Apr 30, 2023

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>
@BorisMolch BorisMolch changed the title ReferenceError: libopenmpt is not defined Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist. Apr 30, 2023
@deskjet
Copy link
Owner

deskjet commented May 1, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants