Network State can determine the network activity.
It returns 4 numbers, from 0 to 3, which correspond to the following states:
networkState is a read-only property.
<!DOCTYPE html> <html> <body> <audio controls> <source src='http://java2s.com/style/demo/your.ogg' type='audio/ogg; codecs=vorbis'> <source src='http://java2s.com/style/demo/your.mp3' type='audio/mpeg'> </audio> <script> let ele = document.querySelector('audio'); function logNetworkState() {/*from ww w. ja v a 2 s .c om*/ console.log(ele.networkState); } </script> </body> </html>