-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathREADME.Rmd
105 lines (70 loc) · 3.62 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
output:
github_document:
html_preview: false
---
# vebmedr
[](https://cran.r-project.org/package=vembedr)
[](https://travis-ci.org/ijlyttle/vembedr)
[](https://codecov.io/github/ijlyttle/vembedr?branch=master)
```{r, echo = FALSE}
library("htmltools")
library("vembedr")
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
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 and 2017 videos).
## New to version 0.1.2.9000 (development)
- New function `embed_user2017()`: embed videos from UseR!2017
## Installation
You can install the latest released version from CRAN with:
```{r eval=FALSE}
install.packages("vembedr")
```
or the latest development version from GitHub with:
```{r eval=FALSE}
# install.packages("devtools")
devtools::install_github("ijlyttle/vembedr")
```
## Note for GitHub README and RStudio viewer
The GitHub Markdown renderer does not support video embedding. To see everything in action, you are invited to visit the [GitHub pages](http://ijlyttle.github.io/vembedr/) site, built using [pkgdown](http://hadley.github.io/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. However, with the advent of the [learnr](https://rstudio.github.io/learnr/) package, the IDE support embedding of Vimeo and YouTube videos.
Otherwise, you can simply open your preview in an external browser.
## Examples
For these examples, it can be useful to load the **htmltools** package along with the **vembedr** package.
```{r}
library("htmltools")
library("vembedr")
```
With the newest function, `embed_url()`, you can use the URL from your browser to embed video:
```{r}
embed_url("https://www.youtube.com/watch?v=uV4UpCq2azs")
```
If you just want the embedding code, the `suggest_embed()` function may be useful:
```{r}
suggest_embed("https://youtu.be/uV4UpCq2azs?t=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.
```{r}
embed_youtube("1-vcErOPofQ")
```
Similarly, to embed a Vimeo, use its identifier. Note that we can apply some formatting by wrapping the output of the `embed_vimeo()` function in an **htmltools** `div()`.
```{r}
div(
align = "center",
embed_vimeo("189919038")
)
```
Hat tip to Karthik Ram for [tweeting](https://twitter.com/_inundata/status/794616331727294464) out this Vimeo.
For YouTube, Vimeo, and Microsoft Channel 9 (hosts of the User! 2016 and 2017 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!2017:
```{r}
embed_user2017("Room-202-Lightning-Talks") %>%
use_start_time("26m35s")
```
## Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.