p5.SoundFile loadSound() autoplay behavior after library upgrade
18.5K reputation · 25 Sept 2023, 19:40 UTC
Goal
Determine whether loadSound() should automatically start playback after a p5.js or p5.sound upgrade, while respecting browser autoplay restrictions.
Constraints
Modern browsers block audio that starts without a user gesture. loadSound() currently returns a p5.SoundFile that must be explicitly played, and the underlying AudioContext begins in a suspended state until resumed.
Uncertainty
Upgrading the library may change the internal initialization of the AudioContext, potentially altering whether loadSound() can resume automatically. It is unclear if the default behavior should remain unchanged or be enhanced with an optional auto‑play flag.
Questions
- Should
loadSound()expose an optionalautoPlayparameter? - If auto‑play is enabled, how can p5.js ensure the
AudioContextis resumed in compliance with browser policies? - What strategy should developers adopt to preserve backward compatibility when upgrading p5.js?