filemonczyk filemonczyk - 1 year ago 76
HTML Question

Displaying mp4 file with html

Hello guys im struggling with displaying gif image in mp4 format:

<video width="320" height="240" >
<source src="" type="video/mp4"/>

that's my code, but only first frame is beeing loaded, then everything freezes.
I have remade it into this:

<!DOCTYPE html>
<meta charset="ISO-8859-1"/>
<title>Insert title here</title>
<video width="320" height="240" >
<source src="" type="video/mp4" autoplay/>

but still its static image.

edit2// I'have added


since In XHTML, attribute minimization is forbidden, and the autoplay attribute must be defined as video autoplay="autoplay".

Answer Source

You need to play the video, too, because by default it will pause at 0:00. There are 3 possible solutions to this problem.

  1. Use the controls attribute (<video ... controls>) to show the controls and play it manually
  2. Use the autoplay attribute (<video ... autoplay>) to autmatically play the video once it has loaded
  3. Get the element via JavaScript and play it there (same behaviour as autoplay in this solution):

    var video = document.getElementById ("videoElement");
    video.addEventListener ("loadedmetadata", function () { (); });

For further information on HTML5-Video attributes, check out MDN:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download