admin管理员组

文章数量:1301821

I am trying to build a video player in website where i want to play the local video defaultly when page first loads without choosing it from the file picker. Where path of the video is known I tried the following code where i am able to play the audio not video. Please help me with this thanks

  <video controls autoplay>
  <source src="small.mp4" type="video/mp4">
 </video>

here the small.mp4 video is stored in the same folder of the html file.

I am trying to build a video player in website where i want to play the local video defaultly when page first loads without choosing it from the file picker. Where path of the video is known I tried the following code where i am able to play the audio not video. Please help me with this thanks

  <video controls autoplay>
  <source src="small.mp4" type="video/mp4">
 </video>

here the small.mp4 video is stored in the same folder of the html file.

Share Improve this question asked Aug 4, 2018 at 9:50 amaresh hiremaniamaresh hiremani 6032 gold badges10 silver badges19 bronze badges 4
  • Browsers are not allowed to load local source, you need to run it from server. Are you running it from server? – Nikola Kirincic Commented Aug 4, 2018 at 9:55
  • i am using the flask framework to run the website locally – amaresh hiremani Commented Aug 4, 2018 at 9:56
  • I think you will have to create a blob with JS – V. Sambor Commented Aug 4, 2018 at 9:57
  • Can you specify how to create blob for my query? – amaresh hiremani Commented Aug 4, 2018 at 10:00
Add a ment  | 

3 Answers 3

Reset to default 5

<video controls autoplay>
  <source src="../Downloads/video.mp4" type="video/mp4">
 </video>

its working fine in my system just go to developer tool and check the path of the video is located in src location or parent location.

In my case, both video and HTML are placed in download folder.

<video controls autoplay>
  <source src="../Downloads/video.mp4" type="video/mp4">
 </video>

When using a video element, you should consider uploading the video to youtube or vimeo to improve page load times. Then you just copy the embed code provided.

本文标签: javascripthow to play mp4 video local file in the htmlStack Overflow