Integral Video Embed
Features
Helps embed videos from known providers like YouTube into HTML
Requirements
Setup
To install, run:
gem install integral-video-embed
Add the following to your Gemfile:
gem "integral-video-embed"
Usage
-
Probably, within a Rails helper:
def bootstrap_embed(uid) Integral::Video::Embed::Bootstrap.html(uid, provider: "YouTube", proportions: "16by9").html_safe end def embed_vk(uid, hash:) Integral::Video::Embed::Generic.html(uid, provider: "Вконтакте").html_safe end
-
and within a Rails view:
= embed_youtube(@video.uid) = embed_vk(@video.uid, @video.uhash)
Labnol embed
This is a very cool technique by Amit Agarwal that allows not to download the YouTube player with its whole bunch of resources for each embedded video — untill the user clicks on it — but instead show a lightweight proxy of a YouTube player (a poster and a button) that looks almost the same as the player.
To use Labnol embed you have to bring CSS / JS dependency. I improved the original code a little and put it right into the gem folder.
-
Copy & paste
vendor/assets/plugins/youtube-labnol-extended-1.3
folder into you Rails/vendor/assets/plugins
folder. -
To include
plugins
folder add it toassets.rb
:Rails.application.config.assets.paths << Rails.root.join("vendor", "assets", "plugins")
-
Make button image (
button.svg
) publicly accessible with help ofapp/assets/config/manifest.js
//= link ../../../vendor/assets/plugins/youtube-labnol-extended-1.3/button.svg
And then as usual:
-
within a Rails helper:
def embed_labnol(uid, thumbnail: nil) Integral::Video::Embed::Labnol.html(uid, thumbnail: thumbnail).html_safe end
-
and within a Rails view:
= embed_labnol(@video.uid)
License
Copyright 2019 Integral Design. Read LICENSE for details.
History
Read CHANGES for details. Built with Gemsmith.
Credits
Developed by Sergey Pedan at Integral Design.