CKTIS / HTML
onloadeddata — handling available media data
The onloadeddata attribute runs code for the loadeddata event when data for the current audio or video playback position first becomes available. It does not mean the entire file has downloaded or playback has started.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
<video onloadeddata="handleData(event)"></video>
<audio onloadeddata="handleData(event)"></audio>
media.onloadeddata = handleData;onloadeddata is an HTML event handler attribute for loadeddata. It is available on HTML elements, but its natural use is primarily with audio and video. Its value is JavaScript code, not a Boolean value.
The browser fires loadeddata when it can first render data at the current playback position during loading: readyState reaches HAVE_CURRENT_DATA (2) or a higher state. For video, this means the current frame is available, not the entire movie. loadedmetadata concerns metadata, whereas canplay indicates that playback can advance at least a little. loadeddata itself does not start playback.
In JavaScript, assign a function to media.onloadeddata; a subsequent assignment replaces the previous handler in that slot. Alternatively, use media.addEventListener('loadeddata', handler). The event name has no on prefix. Content Security Policy can block handlers written directly in attributes.
The example deliberately dispatches a synthetic event. It tests attribute-to-handler wiring and the text update, but does not test media decoding or readiness.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>onloadeddata demo</title>
<audio id="media" onloadeddata="document.getElementById('result').textContent = event.type"></audio>
<p id="result">waiting</p>
<script>
// Synthetic event: tests the handler, not media loading.
document.getElementById('media').dispatchEvent(new Event('loadeddata'));
</script>
</html>Result
loadeddata
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.