The onplaying attribute is an event-handler attribute for <audio> and <video>. It runs JavaScript when the playing event fires — after playback first starts, and whenever it restarts (for example after a pause, or after a delay due to lack of data).
The event is not cancelable and does not bubble. Use it to hide a loading spinner. Contrast with onplay (paused became false) and onwaiting (stalled for data).
Baseline · Widely available.
Not deprecated and not experimental. The playing event is stable across modern browsers since about July 2015.
Prefer addEventListener in apps.
Inline onplaying is fine for learning. Production code usually uses media.addEventListener("playing", handler).
Syntax
HTML Syntax
syntax.html
<video|audio onplaying="script">
script is JavaScript that runs when playing fires. Equivalent JS: media.onplaying = handler or media.addEventListener("playing", handler).
Values
Attribute Values
The attribute value is always a script. Common patterns:
Value / pattern
Description
Try it
script
Any JavaScript run when playback is ready / resumes
playing — frames/audio can advance (after start or resume).
waiting — stalled for data; show a loader.
Local short clips may skip a visible waiting — that’s normal.
Edge Cases & Pitfalls
Most confusion is treating play and playing as the same event.
vs play
play ≠ playing
play means paused became false. playing means playback is ready after start, resume, or buffering.
waiting
Pair with waiting
Show a spinner on waiting; hide it on playing. Short local files often never fire waiting.
restart
Fires again on resume
playing fires after first start and whenever playback restarts after pause or lack of data — not only once per page load.
bubble
Does not bubble
Listen on the audio/video element itself. Parent listeners will not see a bubbling playing.
property
.onplaying = replaces listeners
Assigning the IDL property overwrites a previous assignment. Prefer addEventListener for multiple handlers.
Compatibility
Browser Support
onplaying is an HTML event-handler attribute for media elements in the browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
onplaying
Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support the playing event on audio and video.
97%Global support (approx.)
Google Chrome3+
Full support
Mozilla Firefox3.5+
Full support
Apple Safari3.1+
Full support
Microsoft Edge12+
Full support
Opera10.5+
Full support
Samsung InternetModern · Full
Full support
Internet Explorer9+
Supported
onplayingWidely supported
Bottom line: Safe to use for loading UI. Prefer addEventListener in production, and pair with waiting when you need a buffering indicator.
Remember
Key Takeaways
Role: run script when playback is ready after start or resume.
Trigger: first start, resume after pause, or resume after lack of data.
Pair with:onplay for request; onwaiting for stalls.
UI tip: hide loaders on playing, not only on play.
One line:onplaying means “playback can proceed now” — ideal for clearing buffering UI after start or a stall.
Frequently Asked Questions
It is an event-handler attribute on audio or video. The playing event fires after playback first starts, and whenever it restarts — for example after a pause or after a delay due to lack of data.
The HTML audio and video elements. Put the handler on the media element itself.
onplay means paused became false (playback was requested). onplaying means playback is actually ready to proceed after start, resume, or buffering. Use onplaying to hide loading UI.
onwaiting fires when playback stops because data is missing. onplaying fires when playback can continue again. Pair them for a loading spinner.
Both work. For learning, onplaying in HTML is fine. In production code, prefer media.addEventListener("playing", handler).
No. The playing event and onplaying handler are standard HTML media features and Baseline widely available since about July 2015.