简体   繁体   中英

Checking audio file is playing or not?

After pressing play button audio is playing in html , By calling certain function i want to identify weather the file is playing or player is in idle state?How can i achieve this?Here is my code.

 <!DOCTYPE html>
    <html>
    <body>

    <audio controls>
      <source src="horse.ogg" type="audio/ogg">
    Your browser does not support the audio element.
    </audio>

    </body>
    </html>

Thanks

You're looking for the paused property , which is a boolean indicating whether the media is currently paused or playing.

if($("audio").prop("paused")) {
    ...
}

Or you can do it easily without jQuery:

if(document.getElementById("myAudioId").paused) {
    ...
}

(assuming you give the <audio> tag an id property)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM