如何从同一目录以外的源播放 HTML5 视频

发布于 2024-10-10 08:17:59 字数 341 浏览 0 评论 0原文

我正在尝试使用以下 html5 播放视频:

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

这不会播放我的视频。

如果我将 movie.m4v 文件与 html 文件放在同一目录中,则播放没有问题。像这样:

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

我确信这是一个权限问题,但是如何在网络服务器目录之外访问这个电影文件。

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="movie.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心碎无痕… 2024-10-17 08:17:59

Web 浏览器只是将当前目录与您在 src 标记中写入的任何内容连接起来 - 与 相同的方式作品。

因此,如果您的代码位于 www.mysite.com/index.html 中,则后一个代码段将导致对 www.mysite.com/movie.m4v 的请求,而前一个会向网络服务器请求 www.mysite.com/Users/user1/movie.m4v。您必须确保只需导航到该地址即可从网络浏览器访问该文件。如果它在那里工作,它也将在视频标签中工作。

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.

暖风昔人 2024-10-17 08:17:59

src="/Users/user1/movie.m4v" 翻译为本地 c 驱动器上的 c:/Users/user1/movie.m4v。如果 movie.m4v 位于 src 中 index.html 所在目录下的目录中,则需要像这样读取 src="Users/user1/movie.m4v"

在网站上 src="/Users/user1/movie.m4v" 翻译到 http://thesite.com/Users/user1/movie.m4v 注意上面的case "U" apache 服务器在 Linux 下运行时区分大小写。

您还可以将标签编码到服务器上的地址,然后从本地驱动器打开 html……

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

我假设您需要在本地编辑页面并查看结果。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文