Embedding and customizing videos in RMarkdown documents might seem like complex task. It need not be.
Even the most seemingly-intractable issues can be brought into focus with a clarifying framework.
Above, we used an embed
function followed by a use
function. Using embed_url()
, you can create an embed object for any of these supported services, or you can use an id
with a service-specific embed function:
embed_youtube()
embed_vimeo()
embed_channel9()
embed_box()
embed_msstream()
You can read more about these services in vignette("embed")
. Once you create an embed object, you can modify it with use
functions:
use_start_time()
use_align()
, use_rounded()
use_bs_responsive()
You can read more about these modifications in vignette("modify")
.
To align the video horizontally within its container, use_align()
:
To add rounded corners, use_rounded()
:
If your HTML file uses Bootstrap, and want to make the size responsive to the width of the container, use_bs_responsive()
:
For example this does not work in the R vignette, but it does work in the pkgdown site.
Just because a service publishes a video, this does not mean that you can embed it. For example, this is an amazing Otis Redding performance:
Also, as of RStudio 1.3, the RStudio IDE preview window will work with YouTube and Vimeo, but not with Channel 9:
If you view this page in a full browser, it should work just fine.