如何在 Github 页面 html 上加载视频?

How to Get Videos to Load on Github Pages html?

我正在尝试使用 Github 页面在网页上播放一些视频,我已经将我的视频文件上传到我的存储库,但是当我打开网页时视频没有加载,但是当我在本地 运行 我的 .html 文件时它们可以工作。这是我所拥有的代码片段:

<video width="1280" height="720" controls autoplay muted loop>
<source src="videos/WebIntroG.mp4" type="video/mp4">
 Your browser does not support the video tag.
</video>

我也试过这个:

<video width="1280" height="720" controls autoplay muted loop>
<source src="https://michael1410.github.io/RobotGoon/videos/WebIntroG.mp4" type="video/mp4">
 Your browser does not support the video tag.
</video>

不确定这是否重要,但我的视频文件是用 git-lfs 存储的,它们超过 50MB。谢谢

编辑:所以我上传了一个小于 25 MB 的较小视频文件,并且它有效。所以 我不确定 gitpages 是否会加载存储的大于 50MB 的 .mp4 文件 使用 git-lfs.

与 'autoplay'、'muted' 和 'loop' 一起尝试添加 'playsinline'。它对我有用。

好的,解决方案已由 VonC 在 MP4 file stored with git lfs not playing in Github Pages 发布。对于使用 git-lfs 存储的 .mp4 文件,请使用:

https://media.githubusercontent.com/media/_Username_/_Project_/_Branch_/_Path_to_file_

编辑:请注意,git-lfs 有存储和带宽限制 每月 1GB,购买更多需要 5 美元(5 美元可获得 50 GB)。