Skip to content

video使用技巧

添加playing属性

ts
declare global {

  interface HTMLMediaElement {
    /** 是否在播放 */
    playing: boolean
  }
}

Object.defineProperty(HTMLMediaElement.prototype, 'playing', {
  get: function () {
    const that = this as HTMLMediaElement
    return !!(that.currentTime > 0 && !that.paused && !that.ended && that.readyState > 2);
  }
})

Site developed by Aomd.