目录

AudioContext

has.createAudioContext

has.createAudioContext(string id): AudioContext

Creates an AudioContext object of the internal audio component.

Since: 1.0.16

Parameters

Parameter Type Mandatory Description
id string Yes ID of the audio component.

Returns

AudioContext object.

Example:

const audioContext = has.createAudioContext('myAudio');

AudioContext

AudioContext instance, which can be obtained by calling has.createAudioContext.

AudioContext is bound to an audio component by ID to operate the corresponding audio component.

Since: 1.0.16

[h2]AudioContext.setSrc()

AudioContext.setSrc(string src): void

Sets the audio address.

Since: 1.0.16

Parameters

Parameter Type Mandatory Description
src string Yes Audio address.

Example:

const audioContext = has.createAudioContext('myAudio');
audioContext.setSrc('https://www.example.com/test.mp3'); // Replace the example URL with the actual URL.
audioContext.play();

[h2]AudioContext.play()

AudioContext.play(): void

Plays audio.

Since: 1.0.16

Example:

const audioContext = has.createAudioContext('myAudio');
audioContext.setSrc('https://www.example.com/test.mp3'); // Replace the example URL with the actual URL.
audioContext.play();

[h2]AudioContext.pause()

AudioContext.pause(): void

Pauses audio playback.

Since: 1.0.16

Example:

const audioContext = has.createAudioContext('myAudio');
audioContext.setSrc('https://www.example.com/test.mp3'); // Replace the example URL with the actual URL.
audioContext.pause();

[h2]AudioContext.seek()

AudioContext.seek(number position): void

Seeks to a specified playback position.

Since: 1.0.16

Parameters

Parameter Type Mandatory Description
position number Yes Target position, in seconds.

Example:

const audioContext = has.createAudioContext('myAudio');
audioContext.setSrc('https://www.example.com/test.mp3'); // Replace the example URL with the actual URL.
audioContext.seek(20);