大网数据广告活动
Web 标准与前端开发

AudioData: copyTo() method

· 52CE 我爱测

The **`copyTo()`** method of the AudioData interface copies a plane of an `AudioData` object to a destination buffer.

WebCodecs APIwindow_and_dedicated

The copyTo() method of the AudioData interface copies a plane of an AudioData object to a destination buffer.

Syntax

copyTo(destination, options)

Parameters

  • destination
    • : An ArrayBuffer, a TypedArray, or a DataView to copy the plane to.
  • options
    • : An object containing the following:
      • planeIndex
        • : The index of the plane to copy from.
      • frameOffset
        • : An integer giving the offset of the first frame to copy within the plane. Defaults to 0.
      • frameCount
        • : An integer giving the number of frames to copy. If omitted, all frames from frameOffset to the end of the plane are copied.
      • format
        • : A string indicating the audio format that the source samples should be converted to when copied to the destination. This can be any of the values: "u8", "s16", "s32", "f32", "u8-planar", "s16-planar", "s32-planar", and "f32-planar" (see AudioData.format for more information). Note that "f32-planar" must be supported. If omitted, the samples are copied in the AudioData's own format.

Return value

Undefined.

Exceptions

  • InvalidStateError DOMException
    • : Thrown if the AudioData object has been transferred.
  • RangeError
    • : Thrown if one of the following conditions is met:
      • The length of the sample is longer than the destination length.
      • The format of the AudioData object describes a planar format, but options.planeIndex is outside of the number of planes available.
      • The format of the AudioData object describes an interleaved format, but options.planeIndex is greater than 0.
  • NotSupportedError DOMException
    • : Thrown if the specified format to convert the data to is not supported.

Examples

The following example copies the plane at index 1 to a destination buffer.

AudioData.copyTo(AudioBuffer, { planeIndex: 1 });

Specifications

Browser compatibility

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。