playcanvas / playcanvas/engine

Feature request: sound.play() without a slot name to play the first slot

Open
#3,095 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: sound enhancement
Dominant language
JavaScript
Stars
16.8k
Forks
2k
Avg merge
4h 32m
Merged PRs (30d)
222

Description

Forum: https://forum.playcanvas.com/t/allow-sound-play-to-pass-index-of-sound-by-default-play-first-sound/5952/2?u=yaustar

I’m just flagging this again as a useful and sensible default bahaviour.

If someone does sound.play(), detect that the first parameter is undefined and just play the first sound attached - with a check to see if there is a sound there of course :slight_smile: - as this is very likely what a new, and experienced, dev would want most of the time.

Seems reasonable and I do like the simplicity on single slot sound components

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the sound.play() entry point and trace how the sound component handles its first argument and attached slots. Done means calling sound.play() without a slot name plays the first attached sound when one exists, while safely handling a component with no sound.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
audio-video-rtc, game-dev
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.