简体   繁体   中英

play local video file on a web browser

Okay, I have video files on my network drive which I would like to play on my website, only pc's connected to my network and visit my site will see the files.

So I am trying to use videojs.com to get this working...

If I enter a video file that is hosted online it will play it, entering

file://mybooklive/Public/Shared%20Movies/Anchorman%20(2004).mp4 

it will not play (even though typing that into chrome's URL bar will play the video).

So basically this WILL play a online video...

<video id="my_video_1" class="video-js vjs-default-skin" controls  
preload="auto" width="640" height="264" poster="my_video_poster.png"  
data-setup="{}">  
<source src="http://vjs.zencdn.net/v/oceans.mp4" 
type='video/mp4'> </video>

and this will not play (local file)

<video id="my_video_1" class="video-js vjs-default-skin" controls  
preload="auto" width="640" height="264" poster="my_video_poster.png"  
data-setup="{}">  
<source src="file://mybooklive/Public/Shared%20Movies/Anchorman%20(2004).mp4" 
type='video/mp4'> </video>

Please help!!!

I'm using MyBookLive so I don't think I can enter an IP address.

You are trying to play using your file path, you will need to use the Internet URL absolute path Please change your code, so that the file will be available through URL, and not file system

Using this model, you can place your files anywhere, as long as you point the correct URL to them

Read more about video.js documentation and starting up here

<video id="my_video_1" class="video-js vjs-default-skin" controls  
preload="auto" width="640" height="264" poster="my_video_poster.png"  
data-setup="{}">  
<source src="http://path-to-your-website/Shared%20Movies/Anchorman%20(2004).mp4" 
type='video/mp4'> </video>

Read more about it here

If you don't want to use an absolute path, you can use a relative path , based on where your script is :

<video id="my_video_1" class="video-js vjs-default-skin" controls  
preload="auto" width="640" height="264" poster="my_video_poster.png"  
data-setup="{}">  
<source src="relative-path-to-your-mp4/Anchorman%20(2004).mp4" 
type='video/mp4'> </video>

No need for file:// Put your video in the same folder as your html fime and use,

<video width="640" height="264" controls>
  <source src="filename.mp4" type="video/mp4">
</video>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM