AnnieJS API Docs for: 1.1.3
show:

annie.Sound Class

Extends annie.Media
Defined in: libs/Sound.js:16
Module: annie

Available since 1.0.0

声音类

Methods

_changeMouseCount

(
  • type
  • isAdd
)
private

Inherited from annie.EventDispatcher: libs/EventDispatcher.js:135

Available since 1.0.0

增加或删除相应mouse或touch侦听记数

Parameters:

addEventListener

(
  • type
  • listener
)
public

Inherited from annie.EventDispatcher: libs/EventDispatcher.js:107

Available since 1.0.0

给对象添加一个侦听

Parameters:

  • type String

    侦听类形

  • listener Function

    侦听后的回调方法,如果这个方法是类实例的方法,为了this引用的正确性,请在方法参数后加上.bind(this);

Example:

 this.addEventListener(annie.Event.ADD_TO_STAGE,function(e){trace(this);}.bind(this));

destory

() public

Defined in libs/Sound.js:45

Available since 1.1.1

从静态声音池中删除声音对象,如果一个声音再也不用了,建议先执行这个方法,再销毁

dispatchEvent

(
  • event
  • data
)
Boolean public

Inherited from annie.EventDispatcher: libs/EventDispatcher.js:154

Available since 1.0.0

广播侦听

Parameters:

  • event annie.Event | String

    广播所带的事件对象,如果传的是字符串则直接自动生成一个的事件对象,事件类型就是你传入进来的字符串的值

  • data Object

    广播后跟着事件一起传过去的其他任信息,默认值为null

Returns:

Boolean:

如果有收听者则返回true

Example:

 var mySprite=new annie.Sprite(),
     yourEvent=new annie.Event("yourCustomerEvent");
  yourEvent.data='Flash2x';
  mySprite.addEventListener("yourCustomerEvent",function(e){
     trace(e.data);
   })
  mySprite.dispatchEvent(yourEvent);

hasEventListener

(
  • type
)
Boolean public

Inherited from annie.EventDispatcher: libs/EventDispatcher.js:200

Available since 1.0.0

是否有添加过此类形的侦听

Parameters:

Returns:

Boolean:

如果有则返回true

Media

(
  • src
  • type
)

Inherited from annie.Media: libs/Media.js:25

Available since 1.0.0

构造函数

Parameters:

Example:

 var media = new annie.Media('http://test.annie2x.com/biglong/apiDemo/annieBitmap/resource/music.mp3', 'Audio');
     media.play();//媒体播放
     //media.pause();//暂停播放
     //media.stop();//停止播放

pause

(
  • isPause
)
public

Inherited from annie.Media: libs/Media.js:130

Available since 1.0.4

暂停播放,或者恢复播放

Parameters:

  • isPause Object

    默认为true;是否要暂停,如果要暂停,则暂停;否则则播放

play

(
  • start
  • loop
)
public

Inherited from annie.Media: libs/Media.js:84

Available since 1.0.0

开始播放媒体

Parameters:

  • start Number

    开始点 默认为0

  • loop Number

    循环次数 默认为1

removeAllEventListener

() public

Inherited from annie.EventDispatcher: libs/EventDispatcher.js:237

Available since 1.0.0

移除对象中所有的侦听

removeEventListener

(
  • type
  • listener
)
public

Inherited from annie.EventDispatcher: libs/EventDispatcher.js:214

Available since 1.0.0

移除对应类型的侦听

Parameters:

  • type String

    要移除的侦听类型

  • listener Function

    及侦听时绑定的回调方法

setAllSoundsVolume

(
  • volume
)
public static

Defined in libs/Sound.js:77

Available since 1.1.1

设置当前所有正在播放的声音,当然一定要是annie.Sound类的声音

Parameters:

  • volume Number

    音量大小,从0-1 在ios里 volume只能是0 或者1,其他无效

Sound

(
  • src
)
public

Defined in libs/Sound.js:25

Available since 1.0.0

构造函数

Parameters:

Example:

 var soundPlayer = new annie.Sound('http://test.annie2x.com/biglong/apiDemo/annieBitmap/resource/music.mp3');
     soundPlayer.play();//播放音乐
     //soundPlayer.pause();//暂停音乐
     //soundPlayer.stop();//停止音乐

stop

() public

Inherited from annie.Media: libs/Media.js:120

Available since 1.0.0

停止播放

stopAllSounds

() public static

Defined in libs/Sound.js:59

Available since 1.1.1

停止当前所有正在播放的声音,当然一定要是annie.Sound类的声音

Properties

_MECO

Unknown private

Inherited from annie.EventDispatcher: libs/EventDispatcher.js:254

Available since 1.0.0

全局的鼠标事件的监听数对象表

instanceId

Unknown public

Inherited from annie.AObject: libs/EventDispatcher.js:28

Available since 1.0.0

每一个annie引擎对象都会有一个唯一的id码。

Example:

 //获取 annie引擎类对象唯一码
 trace(this.instanceId);

instanceType

Unknown public

Inherited from annie.AObject: libs/EventDispatcher.js:46

Available since 1.0.3

每一个annie类都有一个实例类型字符串,通过这个字符串,你能知道这个实例是从哪个类实例而来

media

Video | Audio public

Inherited from annie.Media: libs/Media.js:39

Available since 1.0.0

html 标签 有可能是audio 或者 video

volume

Unknown

Inherited from annie.Media: libs/Media.js:147

Available since 1.1.0

设置或者获取音量 从0-1