小游戏不支持 小程序不支持

视频类

Extends annie.Media
Defined in: libs/Video.js:11
Module: annie

Available since 1.0.0

Methods

addEventListener

addEventListener
(
  • type
  • listener
  • useCapture
)
Void public

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

Available since 1.0.0

给对象添加一个侦听

Parameters:

nametypeflagdescription
type String

侦听类型

listener Function

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

useCapture Boolean

true 捕获阶段 false 冒泡阶段 默认 true

Returns:

Void:

Example:

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

destroy

destroy () Void public

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

Available since 2.0.0

销毁一个对象 销毁之前一定要做完其他善后工作,否则有可能会出错 特别注意不能在对象自身方法或事件里调用此方法。 比如,不要在显示对象自身的 annie.Event.ON_REMOVE_TO_STAGE 或者其他类似事件调用,一定会报错

Returns:

Void:

dispatchEvent

dispatchEvent
(
  • event
  • data
  • useCapture
)
Boolean public

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

Available since 1.0.0

广播侦听

Parameters:

nametypeflagdescription
event annie.Event | String

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

data Object

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

useCapture Boolean

true 捕获阶段 false 冒泡阶段 默认 true

Returns:

[Boolean]

如果有收听者则返回true

Example:

 var mySprite=new annie.Sprite(),
 yourEvent=new annie.Event("yourCustomerEvent");
 yourEvent.data={a:1,b:2,c:"hello",d:{aa:1,bb:2}};
 mySprite.addEventListener("yourCustomerEvent",function(e){
     console.log(e.data);
 })
 mySprite.dispatchEvent(yourEvent);

hasEventListener

hasEventListener
(
  • type
  • useCapture
)
Boolean public

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

Available since 1.0.0

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

Parameters:

nametypeflagdescription
type String

侦听类型

useCapture Boolean

true 捕获阶段 false 冒泡阶段 默认 true

Returns:

[Boolean]

如果有则返回true

Media

Media
(
  • src
  • type
)

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

Available since 1.0.0

构造函数

Parameters:

nametypeflagdescription
src String | HtmlElement
type String

Example:

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

pause

pause
(
  • isPause
)
public

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

Available since 1.0.4

暂停播放,或者恢复播放

Parameters:

nametypeflagdescription
isPause Object

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

play

play
(
  • start
  • loop
)
public

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

Available since 1.0.0

开始播放媒体

Parameters:

nametypeflagdescription
start Number

开始点 默认为0

loop Number

循环次数 默认为1

removeAllEventListener

removeAllEventListener () Void public

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

Available since 1.0.0

移除对象中所有的侦听

Returns:

Void:

removeEventListener

removeEventListener
(
  • type
  • listener
  • useCapture
)
Void public

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

Available since 1.0.0

移除对应类型的侦听

Parameters:

nametypeflagdescription
type String

要移除的侦听类型

listener Function

侦听时绑定的回调方法

useCapture Boolean

true 捕获阶段 false 冒泡阶段 默认 true

Returns:

Void:

stop

stop () public

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

Available since 1.0.0

停止播放

Video

Video
(
  • src
  • width
  • height
)
public

Defined in libs/Video.js:21

Available since 1.0.0

构造函数

Parameters:

nametypeflagdescription
src Object
width Object
height Object

Example:

 //切记在微信里视频地址一定要带上完整域名,并且视频尺寸不要超过1136不管是宽还是高,否则后果很严重
 var videoPlayer = new annie.Video('http://test.annie2x.com/biglong/apiDemo/video.mp4');
 videoPlayer.play();//播放视频
 //videoPlayer.pause();//暂停视频
 //videoPlayer.stop();//停止播放
 var floatDisplay=new annie.FloatDisplay();
 floatDisplay.init(videoPlayer);
 //这里的spriteObj是任何一个Sprite类或者其扩展类的实例对象
 spriteObj.addChild(floatDisplay);

Properties

_repeate

Number private

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

Default:

1

instanceId

Number public

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

Available since 1.0.0

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

Example:

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

instanceType

String public

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

Available since 1.0.3

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

isPlaying

Boolean

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

Available since 2.0.0

Default:

true

media

Video | Audio public

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

Available since 1.0.0

html 标签 有可能是audio 或者 video

name

String

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

给一个声音取一个名字,方便获取

type

String

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

Available since 1.0.0

媒体类型 VIDEO 或者 AUDIO

volume

Unknown

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

Available since 1.1.0

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

Top