Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[p5.js 2.0+ Bug Report]: Incorrect isDone assignment in MediaElement.onended() example

Aperta Adatta ai principianti
#9,339 2 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@BhumitSahani ci sta già lavorando.

Dal 27/10/2026.

  • #9346 di @BhumitSahani — aperta

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
86/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript
Ambito
documentation

Direzione di ricerca

Apri l’esempio di riferimento di p5.MediaElement onended() collegato nell’issue e individua il codice handleEnd() mostrato nel suo snippet. Controlla l’assegnazione rispetto alla condizione di draw() che mostra «Done!». Correggi l’esempio in modo che il messaggio di completamento appaia al termine della riproduzione, poi esegui l’esempio e conferma che mostra «Done!» quando l’audio finisce.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Area:DOM p5.js 2.0+
Most appropriate sub-area of p5.js?
  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • WebGPU
  • p5.strands
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)
p5.js version

2.3.2

Web browser and version

Microsoft Edge 156.0.4314.42 (Official build) (64-bit)

Operating system

Windows 11 Version 26H2 (Build 26300.9711)

Steps to reproduce this
Steps:
  1. Open the onended() reference example: https://p5js.org/es/reference/p5.MediaElement/onended/
  2. Run the example and click the canvas to start audio playback.
  3. Wait for the audio to finish. The example is intended to display "Done!", but handleEnd() assigns isDone = false, while draw() displays "Done!" only when isDone === true.
Snippet:
Image

let beat;
let isPlaying = false;
let isDone = false;

function setup() {
  createCanvas(100, 100);

  // Create a p5.MediaElement using createAudio().
  beat = createAudio('/assets/beat.mp3');

  // Call handleEnd() when the beat finishes.
  beat.onended(handleEnd);

  describe('The text "Click to play" written in black on a gray square. A beat plays when the user clicks. The text "Done!" appears when the beat finishes playing.');
}

function draw() {
  background(200);

  // Style the text.
  textAlign(CENTER);
  textSize(16);

  // Display different messages based on playback.
  if (isDone === true) {
    text('Done!', 50, 50);
  } else if (isPlaying === false) {
    text('Click to play', 50, 50);
  } else {
    text('Playing...', 50, 50);
  }
}

// Play the beat when the user presses the mouse.
function mousePressed() {
  if (isPlaying === false) {
    isPlaying = true;
    beat.play();
  }
}

// Set isDone when playback ends.
function handleEnd() {
  isDone = false;
}

Lingua principale
JavaScript
Stelle
24.3k
Fork
3.9k
Merge medio
3g 22h
PR unite (30g)
46

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di processing/p5.js

Tutte le issue di processing/p5.js

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.