Horje
HTML onloadstart Attribute

Definition and Usage

The onloadstart event occurs when the browser starts looking for the specified audio/video. This is when the loading process starts.

During the loading process of an audio/video, the following events occur, in this order:

  1. loadstart
  2. durationchange
  3. loadedmetadata
  4. loadeddata
  5. progress
  6. canplay
  7. canplaythrough

Applies to

The onloadstart attribute is part of the Event Attributes, and can be used on the following elements:

Elements Event
<audio> loadstart
<video> loadstart

Browser Support

The onloadstart attribute has the following browser support for each element:

 


How to Run "myFunction" when the Audio data starts to load - HTML onloadstart Attribute

Play the audio file. This example demonstrates how to use the "onloadstart" attribute on an AUDIO element.
index.html
Example: HTML
<!DOCTYPE html> 
<html> 
<body> 

<audio id="myAudio" controls onloadstart="myFunction()">
  <source src="https://file-examples.com/wp-content/storage/2017/11/file_example_MP3_5MG.mp3" type="audio/ogg">
  <source src="https://file-examples.com/wp-content/storage/2017/11/file_example_MP3_5MG.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

<p>Play the audio file:</p>

<script>
function myFunction() {
  alert("The media file has started loading");
}
</script> 

<p>This example demonstrates how to use the "onloadstart" attribute on an AUDIO element.</p>

</body> 
</html>

Output should be:

How to Run "myFunction" when the Audio data starts to load - HTML onloadstart Attribute

How to Run "myFunction" when the Video data starts to load - HTML onloadstart Attribute

Play the video. This example demonstrates how to use the "onloadstart" attribute on a VIDEO element.
index.html
Example: HTML
<!DOCTYPE html> 
<html> 
<body> 

<video id="myVideo" width="320" height="176" controls onloadstart="myFunction()">
  <source src="https://www.sample-videos.com/video321/mp4/240/big_buck_bunny_240p_2mb.mp4" type="video/mp4">
  <source src="https://www.sample-videos.com/video321/mp4/240/big_buck_bunny_240p_2mb.mp4" type="video/ogg">
  Your browser does not support HTML5 video.
</video>

<p>Play the video:</p>

<script>
function myFunction() {
  alert("The media file has started loading");
}
</script> 

<p>This example demonstrates how to use the "onloadstart" attribute on a VIDEO element.</p>

<p>Video courtesy of <a href="https://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p>

</body> 
</html>

Output should be:

How to Run "myFunction" when the Video data starts to load - HTML onloadstart Attribute




html onloadstart attribute

Type:
Develop
Category:
Web Tutorial
Sub Category:
HTML Attribute
Uploaded by:
Admin


Read Article
https://develop.horje.com/learn/1434/reference