Skip to content

Classes

GlobalDescription
WebAudio

Functions

GlobalDescription
isReady()Boolean

检查音频数据是否准备好播放。 Checks whether the audio data is ready to play.

isError()Boolean

检查是否发生了加载错误。 Checks whether a loading error has occurred.

isPlaying()Boolean

检查音频是否正在播放。 Checks whether the audio is playing.

play(loop, offset)

播放音频。 Plays the audio.

stop()

停止音频。 Stops the audio.

fadeIn(duration)

执行音频淡入。 Performs the audio fade-in.

fadeOut(duration)

执行音频淡出。 Performs the audio fade-out.

WebAudio

Kind: global class

  • WebAudio
    • new WebAudio(url)
    • .initialize(url) ⇒ void
    • .clear() ⇒ void
    • .seek() ⇒ Number
    • .addLoadListener(listner) ⇒ void
    • .addStopListener(listner) ⇒ void

new WebAudio(url)

Web Audio API 音频处理类,提供音频加载、播放和控制功能。
Web Audio API audio processing class providing audio loading, playback and control functionality.

ParamTypeDescription
urlString音频文件的 URL The url of the audio file

WebAudio.initialize(url) ⇒ void

初始化 WebAudio 对象,设置音频系统并加载音频文件。
Initializes the WebAudio object, sets up the audio system and loads the audio file.

Kind: static method of WebAudio
Returns: void - 无返回值 No return value

ParamTypeDescription
urlString音频文件的 URL The url of the audio file

WebAudio.clear() ⇒ void

清除音频数据,停止播放并重置所有音频相关属性。
Clears the audio data, stops playback and resets all audio-related properties.

Kind: static method of WebAudio
Returns: void - 无返回值 No return value


WebAudio.seek() ⇒ Number

获取当前音频播放的位置。
Gets the current playback position of the audio.

Kind: static method of WebAudio
Returns: Number - 当前播放位置(秒) Current playback position in seconds


WebAudio.addLoadListener(listner) ⇒ void

添加音频数据加载完成时的回调函数监听器。
Adds a callback function listener for when audio data loading is complete.

Kind: static method of WebAudio
Returns: void - 无返回值 No return value

ParamTypeDescription
listnerfunction回调函数 The callback function

WebAudio.addStopListener(listner) ⇒ void

添加音频播放停止时的回调函数监听器。
Adds a callback function listener for when audio playback is stopped.

Kind: static method of WebAudio
Returns: void - 无返回值 No return value

ParamTypeDescription
listnerfunction回调函数 The callback function

isReady() ⇒ Boolean

检查音频数据是否准备好播放。
Checks whether the audio data is ready to play.

Kind: global function
Returns: Boolean - 如果音频数据准备好播放则返回 true True if the audio data is ready to play


isError() ⇒ Boolean

检查是否发生了加载错误。
Checks whether a loading error has occurred.

Kind: global function
Returns: Boolean - 如果发生了加载错误则返回 true True if a loading error has occurred


isPlaying() ⇒ Boolean

检查音频是否正在播放。
Checks whether the audio is playing.

Kind: global function
Returns: Boolean - 如果音频正在播放则返回 true True if the audio is playing


play(loop, offset)

播放音频。
Plays the audio.

Kind: global function

ParamTypeDescription
loopBoolean音频数据是否循环播放 Whether the audio data play in a loop
offsetNumber播放的起始位置(秒) The start position to play in seconds

stop()

停止音频。
Stops the audio.

Kind: global function


fadeIn(duration)

执行音频淡入。
Performs the audio fade-in.

Kind: global function

ParamTypeDescription
durationNumber淡入时间(秒) Fade-in time in seconds

fadeOut(duration)

执行音频淡出。
Performs the audio fade-out.

Kind: global function

ParamTypeDescription
durationNumber淡出时间(秒) Fade-out time in seconds

.initialize(noAudio) ⇒ Boolean

初始化音频系统。
Initializes the audio system.

Kind: static function
Returns: Boolean - 如果音频系统可用则返回 true True if the audio system is available

ParamTypeDescription
noAudioBoolean无音频模式的标志 Flag for the no-audio mode

.canPlayOgg() ⇒ Boolean

检查浏览器是否可以播放 ogg 文件。
Checks whether the browser can play ogg files.

Kind: static function
Returns: Boolean - 如果浏览器可以播放 ogg 文件则返回 true True if the browser can play ogg files


.canPlayM4a() ⇒ Boolean

检查浏览器是否可以播放 m4a 文件。
Checks whether the browser can play m4a files.

Kind: static function
Returns: Boolean - 如果浏览器可以播放 m4a 文件则返回 true True if the browser can play m4a files


.setMasterVolume(value)

设置所有音频的主音量。
Sets the master volume of the all audio.

Kind: static function

ParamTypeDescription
valueNumber主音量 (最小值: 0, 最大值: 1) Master volume (min: 0, max: 1)

贡献者

暂无相关贡献者

页面历史

暂无最近变更历史
最近更新