If you can insert a video, you can decorate your website in a fashionable and cool way. This time I will explain in detail how to insert a video into haml with Rails.
Click Create New Folder in a text editor to create a video folder under public.
Bring the video file you want to use under the video folder.
At this time, use mp4 </ font> ** as the extension of the video file! This is because most browsers currently support mp4. This time, we will use a file with the extension mp4, sample_video.mp4.
ruby:◯◯.html.haml
= video_tag("/videos/sample_video.mp4", autoplay: true, loop: true, muted: true, class: 'video')
I will explain one by one. = video_tag It is possible to recall video files using video tags.
/videos/sample_video.mp4 Specify the folder to refer to.
autoplay: true It will be possible to play automatically when the page is refreshed.
loop: true At the end of the video, it will play repeatedly from the beginning.
muted: true It will be played silently.
Then the video will be displayed on the website like this!
Like this time, if you specify the class, you can change the layout of the video with scss!
Inserting a video was relatively easy, but it took me a while to make a video because it was my first time lol The video was created with iMovie on Mac!
** As a caveat If the size of the video file is too large, it will not be displayed, so save it as small as possible. ** **
Please refer to this article and insert a video to create a stylish and cool website!
Referenced articles [Video tag] Thorough summary of how to embed a video in HTML (site is written in HTML) https://webliker.info/52510/
Recommended Posts