HTMLMediaElement: playing

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

playing 事件在播放准备开始时(之前被暂停或者由于数据缺乏被暂缓)被触发。

是否冒泡
是否可取消
接口 Event
目标 元素
默认行为
事件处理器属性 GlobalEventHandlers.onplaying

示例

以下示例展示了如何为媒体元素的 playing 事件添加一个事件监听器,以在该事件触发时发送一条消息。

使用 addEventListener()

js
const video = document.querySelector("video");

video.addEventListener("playing", (event) => {
  console.log("Video is no longer paused");
});

使用 onplaying 事件处理器属性:

js
const video = document.querySelector("video");

video.onplaying = (event) => {
  console.log("Video is no longer paused.");
};

规范

Specification
HTML Standard
# event-media-playing
HTML Standard
# handler-onplaying

浏览器兼容性

BCD tables only load in the browser

相关事件

参见