您的位置:主页 > 营销知识 > 建站资讯 > HTML5中media元素的DOM接口
enum CanPlayTypeEnum { "" /* empty string */, "maybe", "probably" }; interface HTMLMediaElement : HTMLElement { // error state readonly attribute MediaError? error; // network state attribute DOMString src; readonly attribute DOMString currentSrc; attribute DOMString crossOrigin; const unsigned short NETWORK_EMPTY = 0; const unsigned short NETWORK_IDLE = 1; const unsigned short NETWORK_LOADING = 2; const unsigned short NETWORK_NO_SOURCE = 3; readonly attribute unsigned short networkState; attribute DOMString preload; readonly attribute TimeRanges buffered; void load(); CanPlayTypeEnum canPlayType(DOMString type); // ready state const unsigned short HAVE_NOTHING = 0; const unsigned short HAVE_METADATA = 1; const unsigned short HAVE_CURRENT_DATA = 2; const unsigned short HAVE_FUTURE_DATA = 3; const unsigned short HAVE_ENOUGH_DATA = 4; readonly attribute unsigned short readyState; readonly attribute boolean seeking; // playback state attribute double currentTime; readonly attribute unrestricted double duration; Date getStartDate(); readonly attribute boolean paused; attribute double defaultPlaybackRate; attribute double playbackRate; readonly attribute TimeRanges played; readonly attribute TimeRanges seekable; readonly attribute boolean ended; attribute boolean autoplay; attribute boolean loop; void play(); void pause(); // media controller attribute DOMString mediaGroup; attribute MediaController? controller; // controls attribute boolean controls; attribute double volume; attribute boolean muted; attribute boolean defaultMuted; // tracks readonly attribute AudioTrackList audioTracks; readonly attribute VideoTrackList videoTracks; readonly attribute TextTrackList textTracks; TextTrack addTextTrack(TextTrackKind kind, optional DOMString label = "", optional DOMString language = ""); };
媒体元素的属性,src, crossorigin, preload, autoplay, mediagroup, loop, muted, 和 controls,适用于所有的媒体元素。
媒体元素用于向用户呈现音频数据或视频和混合音视频。这一部分被称为媒体数据,因此本节同样适用于media元素,音频或视频的媒体元素。术语“媒体资源”用于指完整的媒体数据集,例如完整的视频文件或完整的音频文件。
媒体资源可以有多个音轨和音轨。对于一个媒体元素的目的,媒体资源的视频数据只显示当前选择的轨道(如果有的话)的元素的videotracks属性,媒体资源的音频数据是混合所有目前启用跟踪的结果(如果有)的元素的audiotracks属性。
音频和视频元素都可以用于音频和视频。两者之间的主要区别仅仅是音频元素没有可视内容的回放区域(如视频或字幕),而视频元素则没有。
除非另有明确指定,在本节及其子部分中列出的所有任务的任务源都是媒体元素中的媒体元素事件任务源。
原文标题:HTML5中media元素的DOM接口
上海云轩网络版权所有 Copyright©2008-2018 http://www.lvon8.com All Rights Reserved 备案号:沪ICP备14049216号