I am trying to display HTML5 video in my Rails 3 app in development,i am using Sqlite3 and default webserver(Webrick).I put the video file (movie.ogg) under assets (assets/m
To serve videos as static assets in Rails 4, the best way is to use the video tag:
Simply create a folder in 'assets' called 'videos' and store your videos there:
app/assets/videos/mycoolvideo.mp4
Then in your views:
<%= video_tag "mycoolvideo.mp4" %>
If you need to specify size, a poster image or add controls, add (but this is HTML, not Rails):
<%= video_tag "mycoolvideo.mp4", width: "640", height: "480", poster: "mycoolvideo.jpg", controls: true %>
Note that Rails cleverly knows that the image is in the image folder, so specifying a name is enough, without adding images/ or assets/images/ before the image name.
If you want to pass in many videos (or better said, the same video in different formats), pass an array:
<%= video_tag ["mycoolvideo.mp4", "mycoolvideo.ogg", "mycoolvideo.webm"], size: "620x480", controls: true %>
Note that for sizing you can either use size: "widthxheight" ("640x360") or separately height: and width: