Title: | Embed Video in HTML |
---|---|
Description: | A set of functions for generating HTML to embed hosted video in your R Markdown documents or Shiny applications. |
Authors: | Ian Lyttle [aut, cre] , Schneider Electric [cph] |
Maintainer: | Ian Lyttle <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.5.9000 |
Built: | 2024-10-26 03:09:57 UTC |
Source: | https://github.com/ijlyttle/vembedr |
The vembedr package lets you embed video into your HTML pages for these services:
YouTube
Vimeo
Box
Microsoft Stream
It provides two categories of functions:
embed functions, to specify a video to embed:
e.g. embed_youtube()
, embed_url()
use functions, to modify the embedding:
e.g. use_start_time()
, use_rounded()
You can use the pipe (|>
or %>%
) to chain embed function-calls with
use function-calls.
These functions are used to embed video into your rmarkdown html-documents, or into your shiny apps. There are functions to embed from YouTube, Vimeo, Microsoft Channel 9 (who host the UseR! 2016 videos), and Box.
embed_box( id, custom_domain = getOption("vembedr.box_custom_domain"), width = NULL, height = 300, ratio = c("16by9", "4by3"), frameborder = 0, allowfullscreen = TRUE ) embed_msstream( id, width = NULL, height = 300, ratio = c("16by9", "4by3"), query = NULL ) embed_vimeo( id, width = NULL, height = 300, ratio = c("16by9", "4by3"), frameborder = 0, allowfullscreen = TRUE, query = NULL, fragment = NULL ) embed_youtube( id, width = NULL, height = 300, ratio = c("16by9", "4by3"), frameborder = 0, allowfullscreen = TRUE, query = NULL )
embed_box( id, custom_domain = getOption("vembedr.box_custom_domain"), width = NULL, height = 300, ratio = c("16by9", "4by3"), frameborder = 0, allowfullscreen = TRUE ) embed_msstream( id, width = NULL, height = 300, ratio = c("16by9", "4by3"), query = NULL ) embed_vimeo( id, width = NULL, height = 300, ratio = c("16by9", "4by3"), frameborder = 0, allowfullscreen = TRUE, query = NULL, fragment = NULL ) embed_youtube( id, width = NULL, height = 300, ratio = c("16by9", "4by3"), frameborder = 0, allowfullscreen = TRUE, query = NULL )
id |
|
custom_domain |
|
width |
|
height |
|
ratio |
|
frameborder |
|
allowfullscreen |
|
query |
|
fragment |
|
These services allow you to customize a lot of things by specifying an optional query string. The specification for the query string will differ according to the service being used:
https://developer.box.com/guides/embed/box-embed/#programmatically
Object with S3 class vembedr_embed
.
embed_youtube("dQw4w9WgXcQ") embed_vimeo("45196609") embed_box("m5do45hvzw32iv2aors3urf5pgkxxazx") embed_msstream("ae21b0ac-4a2b-41f4-b3fc-f1720dd20f48")
embed_youtube("dQw4w9WgXcQ") embed_vimeo("45196609") embed_box("m5do45hvzw32iv2aors3urf5pgkxxazx") embed_msstream("ae21b0ac-4a2b-41f4-b3fc-f1720dd20f48")
You can use this function to embed video using only the URL and you do not
need any customization beyond the start-time. It works for all the
services supported by the embed()
family of functions.
embed_url(url)
embed_url(url)
url |
|
This function calls suggest_embed()
then parses and evaluates the code.
Object with S3 class vembedr_embed
.
embed_url("https://youtu.be/1-vcErOPofQ?t=28s")
embed_url("https://youtu.be/1-vcErOPofQ?t=28s")
These functions are deprecated: links to Microsoft Channel 9 no longer work.
embed_user2016( id, width = NULL, height = 300, ratio = c("16by9", "4by3"), frameborder = 0, allowfullscreen = TRUE ) embed_user2017( id, width = NULL, height = 300, ratio = c("16by9", "4by3"), frameborder = 0, allowfullscreen = TRUE ) rickroll_channel9(...) embed_channel9( id, width = NULL, height = 300, ratio = c("16by9", "4by3"), frameborder = 0, allowfullscreen = TRUE )
embed_user2016( id, width = NULL, height = 300, ratio = c("16by9", "4by3"), frameborder = 0, allowfullscreen = TRUE ) embed_user2017( id, width = NULL, height = 300, ratio = c("16by9", "4by3"), frameborder = 0, allowfullscreen = TRUE ) rickroll_channel9(...) embed_channel9( id, width = NULL, height = 300, ratio = c("16by9", "4by3"), frameborder = 0, allowfullscreen = TRUE )
id |
|
width |
|
height |
|
ratio |
|
frameborder |
|
allowfullscreen |
|
... |
arguments (other than |
Object with S3 class vembedr_embed
.
Determine service based on URL
get_service(url)
get_service(url)
url |
|
character
identifying the video service
get_service("https://youtu.be/1-vcErOPofQ?t=28s")
get_service("https://youtu.be/1-vcErOPofQ?t=28s")
If you want to experiment with the arguments to embed()
,
such as query
, but do not have a particular video in mind, this function
may be useful to you.
rickroll_vimeo(...) rickroll_youtube(...)
rickroll_vimeo(...) rickroll_youtube(...)
... |
arguments (other than |
Please note that the YouTube video seems no longer embeddable.
Object with S3 class vembedr_embed
.
rickroll_vimeo() rickroll_youtube()
rickroll_vimeo() rickroll_youtube()
Use this function to specify the horizontal alignment of the iframe
within the enclosing div
.
use_align(embed, align = c("left", "right", "center", "justified"))
use_align(embed, align = c("left", "right", "center", "justified"))
embed |
|
align |
|
Object with S3 class vembedr_embed
.
If your HTML page includes
Twitter Bootstrap 3,
you can use this function to make the size of the iframe
responsive
within the enclosing div
.
use_bs_responsive(embed)
use_bs_responsive(embed)
embed |
|
Object with S3 class vembedr_embed
.
You can use this function to make rounded corners for the enclosing </div>
.
use_rounded(embed, radius = NULL)
use_rounded(embed, radius = NULL)
embed |
|
radius |
|
Object with S3 class vembedr_embed
.
This function provides you a consistent way to specify the start time, regardless of the service. Please note that Box does not provide a means to specify the start time.
## S3 method for class 'vembedr_embed_box' use_start_time(embed, ...) ## S3 method for class 'vembedr_embed_channel9' use_start_time(embed, start_time, is_paused = TRUE, ...) ## S3 method for class 'vembedr_embed_msstream' use_start_time(embed, start_time, ...) ## S3 method for class 'vembedr_embed_vimeo' use_start_time(embed, start_time, ...) ## S3 method for class 'vembedr_embed_youtube' use_start_time(embed, start_time, ...) use_start_time(embed, ...) ## Default S3 method: use_start_time(embed, ...)
## S3 method for class 'vembedr_embed_box' use_start_time(embed, ...) ## S3 method for class 'vembedr_embed_channel9' use_start_time(embed, start_time, is_paused = TRUE, ...) ## S3 method for class 'vembedr_embed_msstream' use_start_time(embed, start_time, ...) ## S3 method for class 'vembedr_embed_vimeo' use_start_time(embed, start_time, ...) ## S3 method for class 'vembedr_embed_youtube' use_start_time(embed, start_time, ...) use_start_time(embed, ...) ## Default S3 method: use_start_time(embed, ...)
embed |
|
... |
generic arguments to pass through |
start_time |
|
is_paused |
|
The start_time
argument can take a variety of formats; these inputs
all evaluate to the same value:
"0h1m0s"
, "0h01m00s"
, "0h1m"
"1m0s"
, "1m"
"60s"
, 60
Please note that for Vimeo, you can specify a start time, but you can not
specify that the video be paused at this time. In other words, it is like
"autoplay" is set to TRUE
, and you cannot unset it.
Object with S3 class vembedr_embed
.
rickroll_youtube() %>% use_start_time("3m32s")
rickroll_youtube() %>% use_start_time("3m32s")
Knowledge of these classes is not needed for day-to-day use. Rather, it is a bookkeeping device used to make it clearer to a developer how to add a new service.
We use S3 classes to distinguish an embed object, and to denote which
service it uses. Objects of these classes are created by embed_url()
and each service's embed function.
vembedr_embed
base class for all services
HTML <div>
contains the embed code
There is an additional class attached according to the service:
vembedr_embed_youtube
vembedr_embed_youtube_short
vembedr_embed_vimeo
vembedr_embed_channel9
vembedr_embed_box
vembedr_embed_msstream
To support parsing, there is an internal S3 class attached to the URL being processed. It is named according to the service:
vembedr_url_youtube
vembedr_url_youtube_short
vembedr_url_vimeo
vembedr_url_channel9
vembedr_url_box
vembedr_url_msstream