Class MediaStreamClip

包装实时音视频流,仅用于 AVCanvas

⚠️ 不可用于 Combinator ,因为后台合成视频的速度是快于物理时间的,实时流无法提供非实时的数据

Example

const spr = new VisibleSprite(
new MediaStreamClip(
await navigator.mediaDevices.getUserMedia({ video: true, audio: true, }),
),
);
await avCvs.addSprite(spr);

Implements

Constructors

Properties

#cvs: null | OffscreenCanvas = null
#meta: {
    duration: number;
    height: number;
    width: number;
} = ...

Type declaration

  • duration: number
  • height: number
  • width: number
#ms: MediaStream
audioTrack: null | MediaStreamAudioTrack

实时流的音轨

ready: Promise<IClipMeta>

当素材准备完成,ready 会切换到 resolved 状态

ctx: null | AudioContext = null

Accessors

  • get meta(): {
        duration: number;
        height: number;
        width: number;
    }
  • 数据元数据

    Returns {
        duration: number;
        height: number;
        width: number;
    }

    • duration: number
    • height: number
    • width: number

Methods

  • Returns Promise<{
        audio: Float32Array[];
        state: "success";
        video: null | ImageBitmap;
    }>