PROWAREtech
JavaScript: Tutorial - A Guide to JavaScript - Page 20
Media Elements (AUDIO, VIDEO).
Media Elements
HTML5 introduces two media-related elements to enable cross-browser audio and
video embedding into a browser baseline by using the new elements <audio>
and
<video>
.
PROPERTY NAME | DATA TYPE | DESCRIPTION |
---|---|---|
autoplay | Boolean | Gets or sets the autoplay flag. |
buffered | TimeRanges | An object indicating the buffered time ranges that have already been downloaded. |
bufferedBytes | ByteRanges | An object indicating the buff ered byte ranges that have already been downloaded. |
bufferingRate | Integer | The average number of bits per second received from the download. |
bufferingThrottled | Boolean | Indicates if the buff ering has been throttled by the browser. |
controls | Boolean | Gets or sets the controls attribute, which displays or hides the browser's built-in controls. |
currentLoop | Integer | The number of loops that the media has played. |
currentSrc | String | The URI for the currently playing media. |
currentTime | Float | The number of seconds that have been played. |
defaultPlaybackRate | Float | Gets or sets the default playback rate. By default, this is 1.0 seconds. |
duration | Float | The total number of seconds for the media. |
ended | Boolean | Indicates if the media has completely played. |
loop | Boolean | Gets or sets whether the media should loop back to the start when finished. |
muted | Boolean | Gets or sets if the media is muted. |
networkState | Integer | Indicates the current state of the network connection for the media: 0 for empty, 1 for loading, 2 for loading meta data, 3 for loaded fi rst frame, and 4 for loaded. |
paused | Boolean | Indicates if the player is paused. |
playbackRate | Float | Gets or sets the current playback rate. This may be affected by the user causing the media to play faster or slower, unlike defaultPlaybackRate, which remains unchanged unless the developer changes it. |
played | TimeRanges | The range of times that have been played thus far. |
readyState | Integer | Indicates if the media is ready to be played. Values are 0 if the data is unavailable, 1 if the current frame can be displayed, 2 if the media can begin playing, and 3 if the media can play from beginning to end. |
seekable | TimeRanges | The ranges of times that are available for seeking. |
seeking | Boolean | Indicates that the player is moving to a new position in the media file. |
src | String | The media file source. This can be rewritten at any time. |
start | Float | Gets or sets the location in the media file, in seconds, where playing should begin. |
totalBytes | Integer | The total number of bytes needed for the resource (if known). |
videoHeight | Integer | Returns the height of the video (not necessarily of the element). Only for <video> . |
videoWidth | Integer | Returns the width of the video (not necessarily of the element). Only for <video> . |
volume | Float | Gets or sets the current volume as a value between 0.0 and 1.0. |
EVENT NAME | FIRES WHEN |
---|---|
abort | Downloading has been aborted. |
canplay | Playback can begin; readyState is 2. |
canplaythrough | Playback can proceed and should be uninterrupted; readyState is 3. |
canshowcurrentframe | The current frame has been downloaded; readyState is 1. |
dataunavailable | Playback can't happen because there's no data; readyState is 0. |
durationchange | The duration property value has changed. |
emptied | The network connection has been closed. |
empty | An error occurs that prevents the media download. |
ended | The media has played completely through and is stopped. |
error | A network error occurred during download. |
load | All of the media has been loaded. This event is considered deprecated; use canplaythrough instead. |
loadeddata | The first frame for the media has been loaded. |
loadedmetadata | The meta data for the media has been loaded. |
loadstart | Downloading has begun. |
pause | Playback has been paused. |
play | The media has been requested to start playing. |
playing | The media has actually started playing. |
progress | Downloading is in progress. |
ratechange | The speed at which the media is playing has changed. |
seeked | Seeking has ended. |
seeking | Playback is being moved to a new position. |
stalled | The browser is trying to download, but no data is being received. |
timeupdate | The currentTime is updated in an irregular or unexpected way. |
volumechange | The volume property value or muted property value has changed. |
waiting | Playback is paused to download more data. |
Comment