Detect if audio is playing in browser Javascript

前端 未结 5 1128
萌比男神i
萌比男神i 2020-12-31 04:49

Is there a global way to detect when audio is playing or starts playing in the browser.

something like along the idea of if(window.mediaPlaying()){...

5条回答
  •  自闭症患者
    2020-12-31 04:56

    I was looking for a solution in Google, but i didn't find anything yet. Maybe you could check some data that has X value only when audio is playing. If you have some button that start playing the audio file, maybe you can be sure that the audio is playing by adding some event listener on the rep. button...

    Maybe something like adding an event listener to the "audio" tag? If i remember correctly, audio tag has a "paused" attribute... And now i just remember that the audio has "paused" attribute...

    Also, you may want to check this topic HTML5 check if audio is playing?

    i jus find it five seconds ago jaja

提交回复
热议问题