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

Tone.Players onload callback doesn't fire when there's more than one player #1184

Open
ifjorissen opened this issue May 3, 2023 · 2 comments

Comments

@ifjorissen
Copy link

Describe the bug
Players.onload callback doesn't seem to be invoked if the Players object is constructed with more than one audio file / buffer.

To Reproduce

The code snippet below is taken from Players.test.ts.

I imagine that if you added a second item to the url audio buffer map and ran the test, that the onload callback would not fire & the test would fail.

		it("can pass in additional args in the second parameters", (done) => {
			const players = new Players({
				test: "./audio/sine.wav",
			}, {
				onload: () => {
					expect(players.player("test").buffer.loaded).to.be.true;
					expect(players.volume.value).to.be.closeTo(-12, 0.1);
					players.dispose();
					done();
				},
				volume: -12,
			});
		});

Expected behavior
I expected the onload callback to be fired when both/all buffers have been loaded.

What I've tried
With just one item in the map, I verified that the onload callback fires. With more than one, it doesn't seem to work. In my personal code, I even replaced the audio file of the second player to be the same audio file as the first player, and the onload callback never fired.

  const audioSamples = new Tone.Players({
    sampleA: "assets/some_valid_url.m4a",
    sampleB: "assets/some_valid_url.m4a", // `onload` never called even if I use the same file!
  }, {
    onload: () => {
     // this line never seems to fire.
      console.log('loaded audio');
    },
    onerror: (e) => {
      console.log('players error ', e);
    },
  });
@ifjorissen
Copy link
Author

ifjorissen commented May 3, 2023

Update:

This could be an issue with ToneAudioBuffers-- I don't see any test that confirms that onload is called when multiple urls are provided. (https://github.com/Tonejs/Tone.js/blob/master/Tone/core/context/ToneAudioBuffers.test.ts)

@DarshanDixit05
Copy link

I want to work on this issue , please assign it to me.

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