Classes
Global | Description |
---|---|
WebAudio |
Functions
Global | Description |
---|---|
clear() | 清除音频数据。 Clears the audio data. |
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. |
seek() | 获取音频的搜索位置。 Gets the seek position of the audio. |
addLoadListener(listner) | 添加音频数据加载时调用的回调函数。 Add a callback function that will be called when the audio data is loaded. |
addStopListener(listner) | 添加播放停止时调用的回调函数。 Add a callback function that will be called when the playback is stopped. |
WebAudio
Kind: global class
new WebAudio(url)
Web Audio API 的音频对象。
The audio object of Web Audio API.
Param | Type | Description |
---|---|---|
url | String | 音频文件的 URL The url of the audio file |
clear()
清除音频数据。
Clears the audio data.
Kind: global 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
Param | Type | Description |
---|---|---|
loop | Boolean | 音频数据是否循环播放 Whether the audio data play in a loop |
offset | Number | 播放的起始位置(秒) The start position to play in seconds |
stop()
停止音频。
Stops the audio.
Kind: global function
fadeIn(duration)
执行音频淡入。
Performs the audio fade-in.
Kind: global function
Param | Type | Description |
---|---|---|
duration | Number | 淡入时间(秒) Fade-in time in seconds |
fadeOut(duration)
执行音频淡出。
Performs the audio fade-out.
Kind: global function
Param | Type | Description |
---|---|---|
duration | Number | 淡出时间(秒) Fade-out time in seconds |
seek()
获取音频的搜索位置。
Gets the seek position of the audio.
Kind: global function
addLoadListener(listner)
添加音频数据加载时调用的回调函数。
Add a callback function that will be called when the audio data is loaded.
Kind: global function
Param | Type | Description |
---|---|---|
listner | function | 回调函数 The callback function |
addStopListener(listner)
添加播放停止时调用的回调函数。
Add a callback function that will be called when the playback is stopped.
Kind: global function
Param | Type | Description |
---|---|---|
listner | function | 回调函数 The callback function |
.initialize(noAudio) ⇒ Boolean
初始化音频系统。
Initializes the audio system.
Kind: static function
Returns: Boolean
- 如果音频系统可用则返回 true True if the audio system is available
Param | Type | Description |
---|---|---|
noAudio | Boolean | 无音频模式的标志 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
Param | Type | Description |
---|---|---|
value | Number | 主音量 (最小值: 0, 最大值: 1) Master volume (min: 0, max: 1) |