With the insertion of a video, you can decorate your website with style. This time I will explain in detail how to insert a video in haml with Rails.
create videos folder in public folder
Click Create New Folder in a text editor to create a video folder under public.
insert the video file you want to insert under the video folder
Bring the video file you want to use under the video folder.
At this time, please use mp4** for the extension of the video file! This is because most browsers currently support mp4. This time, use the file with extension mp4, sample_video.mp4.
Write the following in # 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 call a video file using a video tag.
/videos/sample_video.mp4 Specify the folder to browse.
autoplay: true It will be possible to automatically play when the page is updated.
loop: true When the video ends, it will play back repeatedly from the beginning.
muted: true Plays silently.
Then the video will be displayed on the website like this!
Like this time, if you specify the class, you can change the video layout with scss!
At the end
Inserting the video was relatively easy, but it was my first time, so it took time to create the video. The video was created with iMovie on Mac!
**Note: If the size of the video file is too large, it will not be displayed. Save it as small as possible. **
Please insert this video by referring to this article to create a stylish and cool website!
Referenced articles [Video tag] Thorough summary of how to embed video in HTML (site is written in HTML) https://webliker.info/52510/