我无法将视频背景上传到本地服务器上的网站

时间:2016-03-09 09:40:25

标签: ruby-on-rails html5-video

我在视频文件中设置了couple_walk.mp4并在下面编写了代码来上传它,但根本不起作用。我想在标题上显示视频。

<div class = "header-container">
        <div class = "video-container">
            <video preload = "true" autoplay = "autoplay" loop = "loop" volume = "0" poster = "pic.jpg">
                <source src=<%= video_tag("couple_walk.mp4") %> type = "video/mp4" >
            </video>
    </header>

以上的css代码低于

.header-container {
    width: 100%;
    height: 900px;
    border-left: none;
    border-right: none;
    position: relative;
    padding: 20px;
}

.video-container {
    position: absolute;
    top: 0%;
    left: 0%;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

video {
    position: absolute;
    z-index: -1;
    opacity: 0.78;
    width: 100%;

}

任何想法?

1 个答案:

答案 0 :(得分:0)

替换

<video preload = "true" autoplay = "autoplay" loop = "loop" volume = "0" poster = "pic.jpg">
            <source src=<%= video_tag("couple_walk.mp4") %> type = "video/mp4" >
        </video>

<%= video_tag("couple_walk.mp4", controls: true, autobuffer: true, poster: "pic.jpg")

会产生

<video src="/videos/couple_walk.mp4", controls: true, autobuffer: true, poster="/assets/screenshot.png"></video>

参考:http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html