HTML onplaying Event Attribute

Description

The event attribute onplaying occurs when an audio / video file has started playing.

Syntax

<element onplaying="script">

Values

  • scriptThe name of the script to use when the event has been triggered.

Example

<!DOCTYPE HTML>
<html>
<body>

<audio id="myAudio" controls onplaying="myFunction()">  
  <source src="audio.mp3" type="audio/mpeg">
  Your browser does not support the audio tag.
</audio>

<p>Play sound file.</p> 

<script>
function myFunction() {
    alert("Sound file started playing.");
}
</script> 

<p>This example shows how to use the onplaying attribute for an AUDIO element.</p>

</body>
</html>

Supported Tags

<audio> and <video>

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
XXYes3.5XX
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
YesYes4XXX