Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML5 check if audio is playing
Use the following to check if audio is playing −
functionisPlaying(audelem) {
return!audelem.paused;
}
The above code can be used to check ifaudio is playing or not. The audio tag has a paused property.The paused property returns whether the audio/video is paused.
You can also toggle −
functiontogglePause() {
if(newAudio.paused && newAudio.currentTime > 0 && !newAudio.ended) {
newAudio.play();
} else {
newAudio.pause();
}
}Advertisements