The goal of the vembedr package is to make it a little bit easier for you to embed videos into your rmarkdown documents and your shiny apps. Three services are currently supported: YouTube, Vimeo, and Microsoft Channel 9 (including UseR! 2016 videos).
- New function
embed_url()
: given a URL, build the<iframe/>
to embed the video - New function
suggest_embed()
: given a URL from a video's web-page: suggests embedding-code.
You can install the latest released version from CRAN with:
install.packages("vembedr")
or the latest development version from GitHub with:
# install.packages("devtools")
devtools::install_github("ijlyttle/vembedr")
The GitHub Markdown renderer does not support video embedding. To see everything in action, you are invited to visit the GitHub pages site, built using pkgdown.
If you use the RStudio-IDE viewer to preview your work, please note that RStudio have made the design choice not to allow arbitrary external web-content in the IDE, which is wholly appropriate. Simply open your preview in an external browser.
For these examples, it can be useful to load the htmltools package along with the vembedr package.
library("htmltools")
library("vembedr")
With the newest function, embed_url()
, you can use the URL from your browser to embed video:
embed_url("https://www.youtube.com/watch?v=uV4UpCq2azs")
suggest_embed("https://youtu.be/uV4UpCq2azs?t=1m32s")
#> embed_youtube("uV4UpCq2azs") %>%
#> use_start_time("1m32s")
All of the features shown here can be used for all the supported services: YouTube, Vimeo, and Channel 9. Here, the features are mixed-and-matched in the interest of brevity.
To embed a YouTube (or Vimeo, or Channel 9) video you can use its identifier, which you can get from the original URL.
embed_youtube("1-vcErOPofQ")
div(
align = "center",
embed_vimeo("189919038")
)
Hat tip to Karthik Ram for tweeting out this Vimeo.
For YouTube, Vimeo, and Microsoft Channel 9 (hosts of the User! 2016 videos) you can specify a start time. Please note that for Vimeo, specifying a start time implies that the video will be auto-played (which can be annoying).
Here's an example using a lightning presentation from UseR! 2016:
embed_user2016("Day-3-Siepr-130-Ligtning-Talks-100-PM-140-PM") %>%
use_start_time("21m45s")
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.