Class Audio

音频解码播放

Hierarchy

  • Audio

Implements

  • IEventSource<{
        ended: [];
        pause: [];
        play: [];
    }>

Constructors

Properties

Methods

Constructors

  • 构建实例

    Parameters

    • url: String

      音频文件url

    • Optional options: {
          cacheSize?: number;
          chunkQueueLength?: number;
          chunkSize?: number;
      }
      • Optional cacheSize?: number

        音频播放缓存大小,默认 600KB (600*1024)

      • Optional chunkQueueLength?: number

        分块数,默认5

      • Optional chunkSize?: number

        url数据分块获取大小,默认8192

    Returns Audio

Properties

ended: boolean

是否播放完成?

Methods

  • 触发事件

    Parameters

    • type: "ended" | "play" | "pause"

      事件类型

    • Rest ...args: never

      事件参数

    Returns Audio

  • 取消监听

    Parameters

    • type: "ended" | "play" | "pause"
    • handler: (() => void)
        • (): void
        • Returns void

    Returns Audio

  • 添加监听

    Parameters

    • type: "ended" | "play" | "pause"

      Event type

    • handler: (() => void)

      A callback function to process the incomming event

        • (): void
        • Returns void

    Returns Audio

  • 添加一次性监听

    Parameters

    • type: "ended" | "play" | "pause"

      Event type

    • handler: (() => void)

      A callback function to process the incomming event

        • (): void
        • Returns void

    Returns Audio

  • 设置默认播放输出通道

    Parameters

    • output: null | I2sWriter

      I2S输出通道,null表示无默认

    Returns void