Classes
Global | Description |
---|---|
Html5Audio | Html5Audio |
Html5Audio
Html5Audio
Kind: global class
new Html5Audio()
处理 HTML5 音频的静态类
The static class that handles HTML5 Audio.
.setup(url)
设置 HTML5 音频
Sets up the Html5 Audio.
Kind: static function
Param | Type | Description |
---|---|---|
url | String | 音频文件的 URL / The url of the audio file |
.initialize() ⇒ Boolean
初始化音频系统
Initializes the audio system.
Kind: static function
Returns: Boolean
- 如果音频系统可用则返回 true / True if the audio system is available
.clear()
清除音频数据
Clears the audio data.
Kind: static function
.setStaticSe(url)
设置静态 SE 的 URL
Set the URL of static se.
Kind: static function
Param | Type | Description |
---|---|---|
url | String | 静态 SE 的 URL / The URL of static se |
.isReady() ⇒ Boolean
检查音频数据是否准备好播放
Checks whether the audio data is ready to play.
Kind: static function
Returns: Boolean
- 如果音频数据准备好播放则返回 true / True if the audio data is ready to play
.isError() ⇒ Boolean
检查是否发生了加载错误
Checks whether a loading error has occurred.
Kind: static function
Returns: Boolean
- 如果发生了加载错误则返回 true / True if a loading error has occurred
.isPlaying() ⇒ Boolean
检查音频是否正在播放
Checks whether the audio is playing.
Kind: static function
Returns: Boolean
- 如果音频正在播放则返回 true / True if the audio is playing
.play(loop, offset)
播放音频
Plays the audio.
Kind: static 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: static function
.fadeIn(duration)
执行音频淡入
Performs the audio fade-in.
Kind: static function
Param | Type | Description |
---|---|---|
duration | Number | 淡入时间(秒) / Fade-in time in seconds |
.fadeOut(duration)
执行音频淡出
Performs the audio fade-out.
Kind: static function
Param | Type | Description |
---|---|---|
duration | Number | 淡出时间(秒) / Fade-out time in seconds |
.seek() ⇒ Number
获取音频的寻找位置
Gets the seek position of the audio.
Kind: static function
Returns: Number
- 当前播放位置(秒) / Current playback position in seconds
.addLoadListener(listener)
添加在音频数据加载完成时调用的回调函数
Add a callback function that will be called when the audio data is loaded.
Kind: static function
Param | Type | Description |
---|---|---|
listener | function | 回调函数 / The callback function |