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

play() without argument does not work if sprites are defined #109

Open
fabswt opened this issue Jun 8, 2022 · 0 comments
Open

play() without argument does not work if sprites are defined #109

fabswt opened this issue Jun 8, 2022 · 0 comments

Comments

@fabswt
Copy link

fabswt commented Jun 8, 2022

Bug report

If defining sprites on a sound, calling play() without any argument results in an error. Here are examples, make sure to reload the page between two tests.

OK

// test 1 - works fine: plays the whole sound
howl_sound = new Howl({
  src: 'http://tests.localhost/Assets/Audio/A1-004-001.wav',
  format: ['wav'],
});
howl_sound.play();

// test 2 - works fine: plays the sprite
howl_sound = new Howl({
  src: 'http://tests.localhost/Assets/Audio/A1-004-001.wav',
  format: ['wav'],
  sprite: {
    hmm: [100, 450, false],
  },
});
howl_sound.play('hmm');

Not OK

// test 3 - doesn't work: does not play anything
howl_sound = new Howl({
  src: 'http://tests.localhost/Assets/Audio/A1-004-001.wav',
  format: ['wav'],
  sprite: {
    hmm: [100, 450, false],
  },
}).play();

And then, trying to howl_sound.play() again will result in the following error:

Uncaught TypeError: Cannot read properties of undefined (reading '0') at Howl.play (howler.js:826:82)

Ambiguity

I can see how there could be some ambiguity here. If defining a sprite, do we mean to use sprites EXCLUSIVELY? In my use case, I need both sprites and the ability to play parts of the audio (for one and the same piece of audio.)

If play() should always be used with an argument when sprites are defined, then the docs should say so (my apologies if ever they do and I missed it.)

Would make sense to let play() (without argument) work even when sprites are defined.

Version

Tested using https://cdnjs.cloudflare.com/ajax/libs/howler/2.2.3/howler.js

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

1 participant