添加第二个 src 到 video_tag

Adding a second src to video_tag

在 rails 中,我在为此 video_tag 添加第二个视频源时遇到了一些困难。 video_tag 没有记录以及我可以解决这个问题,并希望得到一些输入。

<%= video_tag "demo_video.mp4", :size => "800x450", :controls => true, :type => "video/mp4" %>

也许您没有查看正确的文档。试试这个 link:http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/video_tag。您可以看到文档指出:

If sources is a string, a single video tag will be returned. If sources is an array, a video tag with nested source tags for each source will be returned. The sources can be full paths or files that exists in your public videos directory.

因此您的代码可能如下所示:

<%= video_tag ["demo_video.mp4", "demo_video2.mp4"], :size => "800x450", :controls => true, :type => "video/mp4" %>