This article describes how to embed a video into your document.
Requirements
- A Displayr document.
- A link to wherever the video is hosted. The video needs to be hosted on a video hosting website like YouTube, Wistia, etc., that has an actual video player that can play the video. If you link to a file directly, then the file will be downloaded instead of played. For example, if using YouTube, as in the video above, go to the video, click Share, and then copy the embed code.
Note that to keep your account safe, Displayr runs the code that embeds the video in a separate, isolated area of the page. That area can't see your Displayr login, your documents, or anything else on the page. Displayr loads this isolated area from its own web address, displayrusercontent.com. For more information about how this content is loaded, including what to do if you see an error, see: Security and Interactive Visualizations
Method
- On the page where you want to embed the video, go to Calculation
> Custom Code.
- Click on the page to place the video object.
- Paste the following code into the Code
panel, updating the src in line 8 with the address of your video:
text = "<style>.embed-container
{ position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; }
.embed-container iframe,
.embed-container object,
.embed-container embed
{ position: absolute; top: 0; left: 0; width: 100%; height: 100%; }</style>
<div class='embed-container'><iframe
src='https://www.youtube.com/embed/QILiHiTD3uc'
frameborder='0' allowfullscreen></iframe></div>"
rhtmlMetro::Box(text = text, text.as.html = TRUE)Since YouTube videos are not responsive to size, you can change the width and height settings as you need.
Other video platforms, such as Wistia, have advanced embed options, which can be selected and included in the embed code.
UPCOMING WEBINAR: How to Hand Half Your Job to AI (the Right Half)