简体   繁体   English

<audio>使用 Javascript 的 HTML5 元素状态

[英]<audio> HTML5 element state using Javascript

I was wondering if there was any Javascript method that could help getting information on the state of an audio tag:我想知道是否有任何 Javascript 方法可以帮助获取有关音频标签状态的信息:

  • is the audio playing是音频播放吗
  • has it stopped停止了吗
  • is it muted静音了吗
  • is it paused是否暂停

and the sort.和排序。 I know that we can use play() , pause() and others but not quite sure on how to check in the script that the audio is playing in order to trigger another event/action maybe ?我知道我们可以使用play()pause()等,但不太确定如何检查正在播放音频的脚本以触发另一个事件/动作?

Yes you can check a number of attributes on the HTML5 media elements, a list of which you can find in the W3C HTML5 Specification itself.是的,您可以检查 HTML5 媒体元素的许多属性,您可以在W3C HTML5 规范本身中找到这些属性的列表。

Under the "playback state" list you can see such attributes as paused , muted , ended etc.在“播放状态”列表下,您可以看到pausedmutedended等属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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