HTML5-Audio_Video-属性与事件

HTML媒体元素属性与事件详解
本文详细介绍了HTML媒体元素的只读属性如duration、paused等,可读可写属性如autoplay、loop等,以及video专有属性如poster、width等,并列举了常见媒体事件。

1.只读属性
duration: The duration of the full media clip, in seconds. If the full duration is not known, NaN is returned.
paused: Returns true if the media clip is currently paused. Defaults to true if the clip has not started playing.
ended: Returns true if the media clip has finished playing.
startTime: Returns the earliest possible value for playback start time. This will usually be 0.0 unless the media clip is streamed and earlier content has left the buffer.
error: An error code, if an error has occurred.
currentSrc: Returns the string representing the file that is currently being displayed or loaded. This will match the source element selected by the browser.
preload:有auto,none,metadata三个值,无默认值。
src:视频或音频的来源。
readyState:值的范围是[0,4]中五个整数,分别表示不同的可用状态。例如值为1表明元数据可用,值为4的意义同canplaythrough。
buffered:已缓冲的视频或音频时间范围。

2.可读可写属性
autoplay: Sets the media clip to play upon creation or query whether it is set to autoplay.可在<audio>标记中设置。
loop: Returns true if the clip will restart upon ending or sets the clip to loop (or not loop). 可在<audio>标记中设置。
currentTime: Returns the current time in seconds that has elapsed since the beginning of the playback. Sets currentTime to seek to a specific position in the clip playback.
controls: Shows or hides the user controls, or queries whether they are currently visible. 可在<audio>标记中设置。
volume: Sets the audio volume to a relative value between 0.0 and 1.0, or queries the value of the same.
muted: Mutes or unmutes the audio, or determines the current mute state.
autobuffer: Tells the player whether or not to attempt to load the media file before playback is initiated. If the media is set for auto- playback,this attribute is ignored.可在<audio>标记中设置。
playbackRate:控制播放速度。

3.video专有属性
poster: The URL of an image file used to represent the video content before it has loaded. Think “movie poster.” This attribute can be read or altered to change the poster.
width, height: Read or set the visual display size. This may cause centering, letterboxing, or pillaring if the set width does not match the size of the video itself.
videoWidth, videoHeight: Return the intrinsic or natural width and height of the video. They cannot be set.

4.事件
canplay, canplaythrough, play, pause, volumechange, ended, timeupdate,error, loadeddata, loadedmetadata, playing, seeking, seeked.

 

转载于:https://www.cnblogs.com/shn11160/archive/2012/12/21/2828205.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值