How can I tell if an HTML5 Audio element is playing with Javascript
I have an audio element in a webpage, and I want to ensure that a user is not still playing it when they leave the page. How can I be sure the audio element is not playing when the page is unloaded? So far, I have the following code, but it doesn't seem to work; the dialog that pops up upon unload reports that playing is false even when the audio is playing: <!DOCTYPE HTML><html> <head> <script><!-- Loading Scripts --> function unloadTasks(){ if (playing && !window.confirm("A podcast is playing, and navigating away from this page will stop that. Are you sure you want to go?")) window.alert(