开发者

How to play HTML5 Video from a source other than same directory

I'm trying to play a video with the following html5:

<video src="/Users/user1/movie.m4v" controls="controls">
</video>

This will not play my video.

If I put the movie.m4v file in the same directory as the html file, it plays no problem. Like this:

<video src="mo开发者_Python百科vie.m4v" controls="controls">
</video>

I'm sure this is a permissions thing, but how do I access this movie file outside the webserver directory.


Web browser simply concatenates current directory with whatever you write in the src tag - same way as <img> works.

So, if your code resides in www.mysite.com/index.html the latter snippet will result in request to www.mysite.com/movie.m4v, while the former one will ask web server for www.mysite.com/Users/user1/movie.m4v. You have to make sure that you can access the file from the web browser simply navigating to the address. If it works there, it will work in video tag too.


src="/Users/user1/movie.m4v" translates into c:/Users/user1/movie.m4v on your local c drive. if movie.m4v is in a directory under the directory that index.html is in src needs to read like this src="Users/user1/movie.m4v"

On the website src="/Users/user1/movie.m4v" translates to http://thesite.com/Users/user1/movie.m4v Note the upper case "U" apache servers are case sensitive when running under linux.

You can also code the tag to the address on the server and open the html from your local drive ...

<video src="http://yourserver.com/Users/user1/movie.m4v" controls="controls">
</video>

... I assume you need to edit the page locally and view the results.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜