Wladislaw Kusnezow
Wladislaw Kusnezow

Reputation: 103

HTML-Page does not play video

I am creating a HTML-Page for my local PC for fun and want to implement a video player. I searched for how to do it and found something which I applied to my page:

<video width="400" controls>
  <source src="Videos/test.mp4" type="video/mp4"><source>
</video>

I even tried to embed the source attribute:

<video width="400" src="Videos/test.mp4" controls></video>

Both end up creating a video frame with play button but nothing is played. Even when I click on the play button nothing reacts to my click.

enter image description here

Does anyone unterstand why?

Upvotes: 0

Views: 86

Answers (3)

debugger
debugger

Reputation: 1727

I think it's because you are using <source> tag twice. And you can't use an empty <source>. It should be like :

<video width="400" controls>
  <source src="Videos/test.mp4" type="video/mp4">
</video> 

reference : https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video

Upvotes: 1

YJR
YJR

Reputation: 1202

Try this way it may be work if your src path not correct

Videos/test.mp4 => /Videos/test.mp4

  <video width="400" controls>
      <source src="/Videos/test.mp4" type="video/mp4"><source>
  </video>
  

Upvotes: 0

mtbossa
mtbossa

Reputation: 93

You should check the DevTools (F12) network tab for any errors while fetching the video file. Probably your answer will be there.

Most likely, this has something to do with the file path you've entered in the [src] attribute.

From https://www.w3schools.com/tags/att_video_src.asp:

Possible values:

  • An absolute URL - points to another web site (like src="http://www.example.com/movie.ogg")
  • A relative URL - points to a file within a web site (like src="movie.ogg")

Upvotes: 0

Related Questions