| Package | laya.media |
| Class | public class SoundChannel |
| Inheritance | SoundChannel EventDispatcher Object |
SoundChannel 用来控制程序中的声音。每个声音均分配给一个声道,而且应用程序可以具有混合在一起的多个声道。
SoundChannel 类包含控制声音的播放、暂停、停止、音量的方法,以及获取声音的播放状态、总时间、当前播放时间、总循环次数、播放地址等信息的方法。
| Property | Defined By | ||
|---|---|---|---|
| completeHandler : Handler
播放完成处理器。
| SoundChannel | ||
| duration : Number [read-only]
获取总时间。
| SoundChannel | ||
| isStopped : Boolean = false
表示声音是否已暂停。
| SoundChannel | ||
| loops : int
循环次数。
| SoundChannel | ||
| position : Number [read-only]
获取当前播放时间。
| SoundChannel | ||
| startTime : Number
开始时间。
| SoundChannel | ||
| url : String
声音地址。
| SoundChannel | ||
| volume : Number
音量范围从 0(静音)至 1(最大音量)。
| SoundChannel | ||
| Method | Defined By | ||
|---|---|---|---|
![]() | event(type:String, data:* = null):Boolean
派发事件。
| EventDispatcher | |
![]() | hasListener(type:String):Boolean
检查 EventDispatcher 对象是否为特定事件类型注册了任何侦听器。
| EventDispatcher | |
![]() | isMouseEvent(type:String):Boolean
检测指定事件类型是否是鼠标事件。
| EventDispatcher | |
![]() | off(type:String, caller:*, listener:Function, onceOnly:Boolean = false):EventDispatcher
从 EventDispatcher 对象中删除侦听器。
| EventDispatcher | |
![]() | offAll(type:String = null):EventDispatcher
从 EventDispatcher 对象中删除指定事件类型的所有侦听器。
| EventDispatcher | |
![]() | on(type:String, caller:*, listener:Function, args:Array = null):EventDispatcher
使用 EventDispatcher 对象注册指定类型的事件侦听器对象,以使侦听器能够接收事件通知。
| EventDispatcher | |
![]() | once(type:String, caller:*, listener:Function, args:Array = null):EventDispatcher
使用 EventDispatcher 对象注册指定类型的事件侦听器对象,以使侦听器能够接收事件通知,此侦听事件响应一次后自动移除。
| EventDispatcher | |
pause():void
暂停。
| SoundChannel | ||
play():void
播放。
| SoundChannel | ||
resume():void
继续播放。
| SoundChannel | ||
stop():void
停止。
| SoundChannel | ||
| Method | Defined By | ||
|---|---|---|---|
__runComplete(handler:Handler):void
private
| SoundChannel | ||
| completeHandler | property |
public var completeHandler:Handler播放完成处理器。
| duration | property |
duration:Number [read-only] 获取总时间。
public function get duration():Number| isStopped | property |
public var isStopped:Boolean = false表示声音是否已暂停。
| loops | property |
public var loops:int循环次数。
| position | property |
position:Number [read-only] 获取当前播放时间。
public function get position():Number| startTime | property |
public var startTime:Number开始时间。
| url | property |
public var url:String声音地址。
| volume | property |
volume:Number音量范围从 0(静音)至 1(最大音量)。
public function get volume():Number public function set volume(value:Number):void| __runComplete | () | method |
| pause | () | method |
public function pause():void暂停。
| play | () | method |
public function play():void播放。
| resume | () | method |
public function resume():void继续播放。
| stop | () | method |
public function stop():void停止。