This translation is incomplete. Please help translate this article from English.

Erilaisia tapahtumia lähetetään käsitellessä mediaa, joka on upotettu HTML-dokumentteihin <audio>- ja <video> elementtien avulla; tässä osiossa ne luetellaan ja annetaan hyödyllistä tietoa niiden käyttämisestä.

Event name Description
abort Lähetetään, kun soitto keskeytetään. Tämä tapahtuma lähetetään esimerkiksi, jos media on käynnissä ja käynnistetään alusta uudelleen.
canplay Lähetetään, kun tmedian soittamiseen on tarpeeksi dataa saatavana, ainakin parin ruudun verran. Tämä vastaa HAVE_ENOUGH_DATA readyState -valmiustilaa.
canplaythrough Lähetetään, kun valmiustila muuttuu CAN_PLAY_THROUGH -tilaksi, joka ilmaisee median olevan kokonaisuudessaan soitettavissa ilman keskeytystä, olettaen, että latausnopeus pysyy vähintään nykyisellä tasolla. Se käynnistyy myös, kun soittotilaa vaihdetaan pysäytyksen ja soiton välillä. Huom: Kun currentTime asetetaan käsin, se laukaisee canplaythrough -tapahtuman Firefoxissa, mutta ei välttämättä muissa selaimissa.
durationchange Metadata on latautunut tai muuttunut, joka ilmaisee median keston muutosta. Tämä lähetetään esimerkiksi, kun media on tarpeeksi latautunut, jotta sen kesto tunnetaan.
emptied Media on tyhjentynyt; tämä tapahtuma lähetetään esimerkiksi, jos media on jo latautunut (tai osittain latautunut) ja load() -metodia kutsutaan sen lataamiseksi uudelleen.
encrypted  The user agent has encountered initialization data in the media data.
ended Sent when playback completes.
error Sent when an error occurs.  The element's error attribute contains more information. See HTMLMediaElement.error for details.
interruptbegin Sent when audio playing on a Firefox OS device is interrupted, either because the app playing the audio is sent to the background, or audio in a higher priority audio channel begins to play. See Using the AudioChannels API for more details.
interruptend Sent when previously interrupted audio on a Firefox OS device commences playing again — when the interruption ends. This is when the associated app comes back to the foreground, or when the higher priority audio finished playing. See Using the AudioChannels API for more details.
loadeddata The first frame of the media has finished loading.
loadedmetadata The media's metadata has finished loading; all attributes now contain as much useful information as they're going to.
loadstart Sent when loading of the media begins.
mozaudioavailable Sent when an audio buffer is provided to the audio layer for processing; the buffer contains raw audio samples that may or may not already have been played by the time you receive the event.
pause Sent when playback is paused.
play Sent when playback of the media starts after having been paused; that is, when playback is resumed after a prior pause event.
playing Sent when the media begins to play (either for the first time, after having been paused, or after ending and then restarting).
progress Sent periodically to inform interested parties of progress downloading the media. Information about the current amount of the media that has been downloaded is available in the media element's buffered attribute.
ratechange Sent when the playback speed changes.
seeked Sent when a seek operation completes.
seeking Sent when a seek operation begins.
stalled Sent when the user agent is trying to fetch media data, but data is unexpectedly not forthcoming.
suspend Sent when loading of the media is suspended; this may happen either because the download has completed or because it has been paused for any other reason.
timeupdate The time indicated by the element's currentTime attribute has changed.
volumechange Sent when the audio volume changes (both when the volume is set and when the muted attribute is changed).
waiting Sent when the requested operation (such as playback) is delayed pending the completion of another operation (such as a seek).

You can easily watch for these events, using code such as the following:

var v = document.getElementsByTagName("video")[0];
v.addEventListener("seeked", function() { v.play(); }, true);
v.currentTime = 10.0;

This example fetches the first video element in the document and attaches an event listener to it, watching for the seeked event, which is sent whenever a seek operation completes.  The listener simply calls the element's play() method, which starts playback.

Then, in line 3, the example sets the element's currentTime attribute to 10.0, which initiates a seek operation to the 10-second mark in the media.  This causes a seeking event to be sent when the operation begins, then a seeked event to be dispatched when the seek is completed.

In other words, this example seeks to the 10-second mark in the media, then begins playback as soon as that's finished.

Document Tags and Contributors

Tunnisteet: 
Tämän sivun avustajat: susannaanas
Viimeksi päivittänyt: susannaanas,