From 71911494abc22032b80e4c0eb627b1db30153e8e Mon Sep 17 00:00:00 2001 From: Ian Lyttle Date: Sun, 4 Oct 2020 08:40:18 -0500 Subject: [PATCH] Add Microsoft Stream (#46) * bump version, add to news * add regex to get_service() * get parse-method working * get code working for msstream * - reanme s3 classes for url-parsing - add msstream to meta documentation --- DESCRIPTION | 2 +- NAMESPACE | 2 + NEWS.md | 1 + R/embed.R | 4 +- R/parse.R | 5 ++- R/s3-classes.R | 22 +++++++++- R/service-box.R | 2 +- R/service-channel9.R | 2 +- R/service-msstream.R | 64 ++++++++++++++++++++++++++++ R/service-vimeo.R | 2 +- R/service-youtube.R | 4 +- R/vembedr-package.R | 1 + README.Rmd | 6 ++- README.md | 8 ++-- checklist-new-service.md | 4 +- man/embed.Rd | 16 ++++++- man/use_start_time.Rd | 6 ++- man/vembedr-package.Rd | 1 + man/vembedr-s3-classes.Rd | 21 ++++++++- pkgdown/_pkgdown.yml | 2 +- tests/testthat/test-suggest.R | 28 ++++++++++++ tests/testthat/test-use_start_time.R | 11 +++++ vignettes/embed.Rmd | 52 +++++++++++++++++----- vignettes/vembedr.Rmd | 1 + 24 files changed, 236 insertions(+), 31 deletions(-) create mode 100644 R/service-msstream.R diff --git a/DESCRIPTION b/DESCRIPTION index e538ac2..0c81b03 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: vembedr Title: Embed Video in HTML -Version: 0.1.3.9002 +Version: 0.1.3.9003 Authors@R: c( person( given = "Ian", diff --git a/NAMESPACE b/NAMESPACE index bc45506..4784ae9 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -7,11 +7,13 @@ S3method(set_iframe,vembedr_embed) S3method(use_start_time,default) S3method(use_start_time,vembedr_embed_box) S3method(use_start_time,vembedr_embed_channel9) +S3method(use_start_time,vembedr_embed_msstream) S3method(use_start_time,vembedr_embed_vimeo) S3method(use_start_time,vembedr_embed_youtube) export("%>%") export(embed_box) export(embed_channel9) +export(embed_msstream) export(embed_url) export(embed_user2016) export(embed_user2017) diff --git a/NEWS.md b/NEWS.md index 986ad33..6f92180 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ ## vembedr 0.1.3.9000 +- add support for [Microsoft Stream](https://www.microsoft.com/en-us/microsoft-365/microsoft-stream), which offers an enterprise video service; this will likely be for use internal to an organization. (#38) - if you have a recent version of [usethis](https://usethis.r-lib.org) installed, `suggest_embed()` will copy the suggested code to your clipboard. (#32) - sets the default `height` to 300 pixels, and introduces an argument `ratio`, to set the aspect ratio; legal values are `"16by9"` or `"4by3"`. If you set the `width` and `height`, `ratio` is ignored. If you specify only one of `width` or `height`, `ratio` is used to calculate the other. (#33) - adds three functions to help with formatting; they are all pipeable with `embed_*()` functions: diff --git a/R/embed.R b/R/embed.R index 01b809b..dc3e623 100644 --- a/R/embed.R +++ b/R/embed.R @@ -11,9 +11,10 @@ #' \describe{ #' \item{YouTube}{} #' \item{Vimeo}{} -#' \item{Channel 9}{ +#' \item{Microsoft Channel 9}{ #' (click the *Embed* tab)} #' \item{Box}{} +#' \item{Microsoft Stream}{} #' } #' #' @param id `character`, identifier provided by the service @@ -40,6 +41,7 @@ #' embed_user2016("Literate-Programming") #' embed_user2017("Room-202-Lightning-Talks") %>% use_start_time("26m35s") #' embed_box("m5do45hvzw32iv2aors3urf5pgkxxazx") +#' embed_msstream("ae21b0ac-4a2b-41f4-b3fc-f1720dd20f48") #' NULL diff --git a/R/parse.R b/R/parse.R index 97268ed..8d612ff 100644 --- a/R/parse.R +++ b/R/parse.R @@ -132,7 +132,8 @@ get_service <- function(url) { youtube = "^www\\.youtube\\.com$", youtube_short = "^youtu\\.be$", vimeo = "^vimeo\\.com$", - box = "app\\.box\\.com$" + box = "app\\.box\\.com$", + msstream = "web\\.microsoftstream\\.com$" ) # str_detect is vectorized over the patters @@ -176,7 +177,7 @@ parse_video_url <- function(url) { service <- get_service(url) url_parsed <- httr::parse_url(url) - class(url_parsed) <- c(glue::glue("vembedr_{service}")) + class(url_parsed) <- c(glue::glue("vembedr_url_{service}")) .parse(url_parsed) } diff --git a/R/s3-classes.R b/R/s3-classes.R index 0ef97e3..e3093e9 100644 --- a/R/s3-classes.R +++ b/R/s3-classes.R @@ -1,6 +1,12 @@ #' vembedr S3 Classes #' -#' We use S3 classes to distinguish an embed object, and to denote which service it uses. +#' Knowledge of these classes is not needed for day-to-day use. Rather, +#' it is a bookkeeping device used to make it clearer to add a new service +#' in development. +#' +#' 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`** #' @@ -8,13 +14,27 @@ #' - HTML `
` #' - 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`** #' #' @name vembedr-s3-classes #' NULL + diff --git a/R/service-box.R b/R/service-box.R index f50bbd8..0fb4359 100644 --- a/R/service-box.R +++ b/R/service-box.R @@ -55,7 +55,7 @@ use_start_time.vembedr_embed_box <- function(embed, ...) { } -.parse.vembedr_box <- function(url_parsed, ...) { +.parse.vembedr_url_box <- function(url_parsed, ...) { # determine custom-domain by taking apart hostname hostname_split <- stringr::str_split(url_parsed$hostname, "\\.")[[1]] diff --git a/R/service-channel9.R b/R/service-channel9.R index 43b67eb..036703e 100644 --- a/R/service-channel9.R +++ b/R/service-channel9.R @@ -60,7 +60,7 @@ use_start_time.vembedr_embed_channel9 <- function(embed, start_time, is_paused = embed } -.parse.vembedr_channel9 <- function(url_parsed, ...){ +.parse.vembedr_url_channel9 <- function(url_parsed, ...){ path_split <- url_parsed$path %>% diff --git a/R/service-msstream.R b/R/service-msstream.R new file mode 100644 index 0000000..7d72bee --- /dev/null +++ b/R/service-msstream.R @@ -0,0 +1,64 @@ +#' @rdname embed +#' @export +# +embed_msstream <- function(id, width = NULL, height = 300, + ratio = c("16by9", "4by3"), query = NULL){ + + ratio <- match.arg(ratio) + dim <- get_width_height(width, height, ratio) + + url <- httr::parse_url("https://web.microsoftstream.com/embed/video") + + url$path <- glue::glue("{url$path}/{id}") + url$query <- c(list(autoplay = "false", showinfo = "true"), query) + + iframe <- htmltools::tags$iframe( + src = httr::build_url(url), + width = dim$width, + height = dim$height, + allowfullscreen = NULL, + style = "border:none;" + ) + + embed <- create_embed(iframe, "vembedr_embed_msstream", ratio) + + embed +} + +#' @rdname use_start_time +#' @export +#' +use_start_time.vembedr_embed_msstream <- function(embed, start_time, ...){ + + # get the iframe + iframe <- get_iframe(embed) + + # get the src from the iframe + src <- htmltools::tagGetAttribute(iframe, "src") + + # parse the url + url <- httr::parse_url(src) + + # set the time in url$query + url$query$st <- .secs(start_time) + + # set the url in the iframe + # == need to ask about a public API for this in htmltools == + iframe$attribs$src <- httr::build_url(url) + + # set the iframe in the embed + embed <- set_iframe(embed, iframe) + + embed +} + +.parse.vembedr_url_msstream <- function(url_parsed, ...) { + + path_split <- stringr::str_split(url_parsed$path, "/")[[1]] + + list( + service = "msstream", + id = path_split[[2]], + start_time = url_parsed$query$st + ) +} diff --git a/R/service-vimeo.R b/R/service-vimeo.R index 230d670..b7ba5a2 100644 --- a/R/service-vimeo.R +++ b/R/service-vimeo.R @@ -61,7 +61,7 @@ use_start_time.vembedr_embed_vimeo <- function(embed, start_time, ...){ embed } -.parse.vembedr_vimeo <- function(url_parsed, ...){ +.parse.vembedr_url_vimeo <- function(url_parsed, ...){ start_time <- NULL if (!is.null(url_parsed$fragment)){ diff --git a/R/service-youtube.R b/R/service-youtube.R index 292e244..d9d22ab 100644 --- a/R/service-youtube.R +++ b/R/service-youtube.R @@ -56,7 +56,7 @@ use_start_time.vembedr_embed_youtube <- function(embed, start_time, ...){ embed } -.parse.vembedr_youtube <- function(url_parsed, ...) { +.parse.vembedr_url_youtube <- function(url_parsed, ...) { list( service = "youtube", id = url_parsed$query$v, @@ -64,7 +64,7 @@ use_start_time.vembedr_embed_youtube <- function(embed, start_time, ...){ ) } -.parse.vembedr_youtube_short <- function(url_parsed, ...) { +.parse.vembedr_url_youtube_short <- function(url_parsed, ...) { list( service = "youtube", id = url_parsed$path, diff --git a/R/vembedr-package.R b/R/vembedr-package.R index 0c5663a..dbbf027 100644 --- a/R/vembedr-package.R +++ b/R/vembedr-package.R @@ -7,6 +7,7 @@ #' - Vimeo #' - Microsoft Channel 9 #' - Box +#' - Microsoft Stream #' #' It provides two categories of functions: #' diff --git a/README.Rmd b/README.Rmd index 41d64dd..a369ddb 100644 --- a/README.Rmd +++ b/README.Rmd @@ -32,8 +32,10 @@ The goal of the vembedr package is to make it a little bit easier for you to emb ## New to version 0.1.3.9000 -- functions to help you format: `use_rounded()`, `use_align()`, and `use_bs_responsive()`. -- you can embed videos hosted on Box, using `embed_box()`. +- new functions to help you format: `use_rounded()`, `use_align()`, and `use_bs_responsive()`. +- new services supported: + - Box, using `embed_box()` + - Microsoft Stream, using `embed_msstream()` ## Installation diff --git a/README.md b/README.md index 2348216..3acf506 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,11 @@ apps. Four services are currently supported: ## New to version 0.1.3.9000 - - functions to help you format: `use_rounded()`, `use_align()`, and - `use_bs_responsive()`. - - you can embed videos hosted on Box, using `embed_box()`. + - new functions to help you format: `use_rounded()`, `use_align()`, + and `use_bs_responsive()`. + - new services supported: + - Box, using `embed_box()` + - Microsoft Stream, using `embed_msstream()` ## Installation diff --git a/checklist-new-service.md b/checklist-new-service.md index 4399fdd..3fd7a27 100644 --- a/checklist-new-service.md +++ b/checklist-new-service.md @@ -4,7 +4,7 @@ When adding a new service, say TikTok, we need to make sure that we add it every Maybe split up be service so that we can just add the file. -To determine service: +To determine service, add to regex list: - `get_service()`: `R/parse.R` @@ -19,9 +19,11 @@ Methods based on service: - `R/s3-classes.R` - `R/vembedr-package.R` +- `R/embed.R` - `vignettes/vembedr.Rmd` - `vignettes/embed.Rmd` - `README.Rmd` +- `NEWS.md` ## Other videos diff --git a/man/embed.Rd b/man/embed.Rd index 9902898..ef7e8a2 100644 --- a/man/embed.Rd +++ b/man/embed.Rd @@ -1,12 +1,14 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/embed.R, R/embed_url.R, R/service-box.R, -% R/service-channel9.R, R/service-vimeo.R, R/service-youtube.R +% R/service-channel9.R, R/service-msstream.R, R/service-vimeo.R, +% R/service-youtube.R \name{embed} \alias{embed} \alias{embed_user2016} \alias{embed_user2017} \alias{embed_box} \alias{embed_channel9} +\alias{embed_msstream} \alias{embed_vimeo} \alias{embed_youtube} \title{Embed video from service} @@ -48,6 +50,14 @@ embed_channel9( allowfullscreen = TRUE ) +embed_msstream( + id, + width = NULL, + height = 300, + ratio = c("16by9", "4by3"), + query = NULL +) + embed_vimeo( id, width = NULL, @@ -107,9 +117,10 @@ according to the service being used: \describe{ \item{YouTube}{\url{https://developers.google.com/youtube/player_parameters}} \item{Vimeo}{\url{https://developer.vimeo.com/player/embedding}} -\item{Channel 9}{\url{https://channel9.msdn.com/Events/useR-international-R-User-conference/useR2016/Forty-years-of-S} +\item{Microsoft Channel 9}{\url{https://channel9.msdn.com/Events/useR-international-R-User-conference/useR2016/Forty-years-of-S} (click the \emph{Embed} tab)} \item{Box}{\url{https://developer.box.com/docs/box-embed#section-build-box-embed-programatically}} +\item{Microsoft Stream}{\url{https://docs.microsoft.com/en-us/stream/portal-embed-video}} } } \examples{ @@ -118,6 +129,7 @@ embed_vimeo("45196609") embed_user2016("Literate-Programming") embed_user2017("Room-202-Lightning-Talks") \%>\% use_start_time("26m35s") embed_box("m5do45hvzw32iv2aors3urf5pgkxxazx") +embed_msstream("ae21b0ac-4a2b-41f4-b3fc-f1720dd20f48") } \seealso{ diff --git a/man/use_start_time.Rd b/man/use_start_time.Rd index a2231fd..dd07a61 100644 --- a/man/use_start_time.Rd +++ b/man/use_start_time.Rd @@ -1,9 +1,11 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/service-box.R, R/service-channel9.R, -% R/service-vimeo.R, R/service-youtube.R, R/use_start_time.R +% R/service-msstream.R, R/service-vimeo.R, R/service-youtube.R, +% R/use_start_time.R \name{use_start_time.vembedr_embed_box} \alias{use_start_time.vembedr_embed_box} \alias{use_start_time.vembedr_embed_channel9} +\alias{use_start_time.vembedr_embed_msstream} \alias{use_start_time.vembedr_embed_vimeo} \alias{use_start_time.vembedr_embed_youtube} \alias{use_start_time} @@ -14,6 +16,8 @@ \method{use_start_time}{vembedr_embed_channel9}(embed, start_time, is_paused = TRUE, ...) +\method{use_start_time}{vembedr_embed_msstream}(embed, start_time, ...) + \method{use_start_time}{vembedr_embed_vimeo}(embed, start_time, ...) \method{use_start_time}{vembedr_embed_youtube}(embed, start_time, ...) diff --git a/man/vembedr-package.Rd b/man/vembedr-package.Rd index cd1d72f..63d3344 100644 --- a/man/vembedr-package.Rd +++ b/man/vembedr-package.Rd @@ -14,6 +14,7 @@ these services: \item Vimeo \item Microsoft Channel 9 \item Box +\item Microsoft Stream } It provides two categories of functions: diff --git a/man/vembedr-s3-classes.Rd b/man/vembedr-s3-classes.Rd index ae1ba23..aa02286 100644 --- a/man/vembedr-s3-classes.Rd +++ b/man/vembedr-s3-classes.Rd @@ -4,9 +4,15 @@ \alias{vembedr-s3-classes} \title{vembedr S3 Classes} \description{ -We use S3 classes to distinguish an embed object, and to denote which service it uses. +Knowledge of these classes is not needed for day-to-day use. Rather, +it is a bookkeeping device used to make it clearer to add a new service +in development. } \details{ +We use S3 classes to distinguish an embed object, and to denote which +service it uses. Objects of these classes are created by \code{\link[=embed_url]{embed_url()}} +and each service's embed function. + \strong{\code{vembedr_embed}} \itemize{ \item base class for all services @@ -14,9 +20,22 @@ We use S3 classes to distinguish an embed object, and to denote which service it \item contains the embed code } +There is an additional class attached according to the service: + \strong{\code{vembedr_embed_youtube}} \strong{\code{vembedr_embed_youtube_short}} \strong{\code{vembedr_embed_vimeo}} \strong{\code{vembedr_embed_channel9}} \strong{\code{vembedr_embed_box}} +\strong{\code{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: + +\strong{\code{vembedr_url_youtube}} +\strong{\code{vembedr_url_youtube_short}} +\strong{\code{vembedr_url_vimeo}} +\strong{\code{vembedr_url_channel9}} +\strong{\code{vembedr_url_box}} +\strong{\code{vembedr_url_msstream}} } diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index d8ceb50..b2f4953 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -3,7 +3,7 @@ template: bootswatch: sandstone development: - mode: release # remember to switch back to auto + mode: auto reference: - title: Embed functions diff --git a/tests/testthat/test-suggest.R b/tests/testthat/test-suggest.R index 17a7ccc..6da5194 100644 --- a/tests/testthat/test-suggest.R +++ b/tests/testthat/test-suggest.R @@ -111,6 +111,30 @@ list_suggest_box_acme <- list( start_time = NULL ) +#### +url_msstream <- + "https://web.microsoftstream.com/video/ae21b0ac-4a2b-41f4-b3fc-f1720dd20f48" + +url_msstream_time <- + "https://web.microsoftstream.com/video/ae21b0ac-4a2b-41f4-b3fc-f1720dd20f48?st=10" + +list_parse_msstream <- list( + service = "msstream", + id = "ae21b0ac-4a2b-41f4-b3fc-f1720dd20f48", + start_time = NULL +) + +list_parse_msstream_time <- list( + service = "msstream", + id = "ae21b0ac-4a2b-41f4-b3fc-f1720dd20f48", + start_time = "10" +) + +list_suggest_msstream_time <- list( + embed = "embed_msstream(\"ae21b0ac-4a2b-41f4-b3fc-f1720dd20f48\")", + start_time = "use_start_time(\"10\")" +) + #### url_cran <- "https://cran.rstudio.com/" @@ -136,6 +160,7 @@ test_that("get_service works", { expect_service(url_user2017, "channel9") expect_service(url_box, "box") expect_service(url_box_acme, "box") + expect_service(url_msstream, "msstream") expect_error(get_service(url_cran), regexp = "cran\\.rstudio\\.com") }) @@ -148,6 +173,8 @@ test_that("parse_video_url works", { expect_parse(url_user2017, list_parse_user2017) expect_parse(url_box, list_parse_box) expect_parse(url_box_acme, list_parse_box_acme) + expect_parse(url_msstream, list_parse_msstream) + expect_parse(url_msstream_time, list_parse_msstream_time) expect_error(parse_video_url(url_cran), regexp = "cran\\.rstudio\\.com") }) @@ -160,4 +187,5 @@ test_that("build_suggestion works", { expect_build(list_parse_user2017, list_suggest_user2017) expect_build(list_parse_box, list_suggest_box) expect_build(list_parse_box_acme, list_suggest_box_acme) + expect_build(list_parse_msstream_time, list_suggest_msstream_time) }) diff --git a/tests/testthat/test-use_start_time.R b/tests/testthat/test-use_start_time.R index 83e92d3..263df9f 100644 --- a/tests/testthat/test-use_start_time.R +++ b/tests/testthat/test-use_start_time.R @@ -37,3 +37,14 @@ test_that("box throws a warning", { expect_warning(use_start_time(emb_box, "25s"), "^Start time") }) +test_that("msstream works", { + + emb_msstream <- embed_msstream("foo") %>% use_start_time(10) + + expect_identical( + get_query(emb_msstream)[["st"]], + "10" + ) + +}) + diff --git a/vignettes/embed.Rmd b/vignettes/embed.Rmd index 9d6c4b3..b3d0098 100644 --- a/vignettes/embed.Rmd +++ b/vignettes/embed.Rmd @@ -29,15 +29,18 @@ Using this package, you can embed videos into RMarkdown documents and Shiny apps - [Vimeo](https://developer.vimeo.com/player/embedding) - [Channel 9](https://channel9.msdn.com/Events/useR-international-R-User-conference/useR2016/Forty-years-of-S), which includes the UseR! 2016 and 2017 videos. Click the *Embed* tab for embedding options. - [Box](https://developer.box.com/docs/box-embed#section-build-box-embed-programatically) +- [Microsoft Stream](https://docs.microsoft.com/en-us/stream/portal-embed-video) The links above are associated with the embedding API for each of the services; these are the APIs wrapped by the -`embed()` functions in this packages. In many cases it may be easier to embed by using only URL of the page your video is on, using `embed_url()`. +`embed()` functions in this packages. +In many cases it may be easier to embed by using only URL of the page your video is on, using `embed_url()`. To set the start time, or to change the formatting, check out the `use_*()` functions in `vignette("modify")`. ## Embded using URL -Although a URL can be long and awkward, it will get the job done. If the URL is from one of the supported services, it should *just work*: +Although a URL can be long and awkward, it will get the job done. +If the URL is from one of the supported services, it should *just work*: ```{r} embed_url("https://www.youtube.com/watch?v=uV4UpCq2azs") @@ -59,7 +62,8 @@ You can get your video's identifier by inspecting its URL at YouTube - you can u suggest_embed("https://youtu.be/JeaBNAXfHfQ") ``` -The identifier is the last part of the URL. To embed this video: +The identifier is the last part of the URL. +To embed this video: ```{r} embed_youtube("JeaBNAXfHfQ") @@ -73,7 +77,7 @@ For Vimeo, the identifier is also included in the standard URL: suggest_embed("https://vimeo.com/238200347") ``` -The Vimeo identifier is the path part of the URL: +The Vimeo identifier is the path of the URL: ```{r} embed_vimeo("238200347") @@ -83,7 +87,9 @@ embed_vimeo("238200347") The UseR! 2016 and 2017 videos are hosted on Microsoft's Channel 9 service, motivating this embed function. -Personal note: one of the things I want to well-and-truly understand (along with non-standard evaluation) is monads. I understand it to be a useful construct for managing side-effects, but true understanding escapes me. This is a great video; it gets me 95% of the way there (I think), so maybe repeated viewings will get me sufficiently close. +Personal note: one of the things I want to well-and-truly understand (along with non-standard evaluation) is monads. +I understand it to be a useful construct for managing side-effects, but true understanding escapes me. +This is a wonderful presentation; it gets me 95% of the way there (I think), so maybe repeated viewings will get me sufficiently close. Here's the URL: @@ -120,7 +126,8 @@ tags$p( ) ``` -For a UseR!2016 (or 2017) video, the identifier is the last component of path of the URL, in this case: **`Forty-years-of-S`**. To embed the video: +For a UseR!2016 (or 2017) video, the identifier is the last component of path of the URL, in this case: **`Forty-years-of-S`**. +To embed the video: ```{r} embed_user2016("Forty-years-of-S") @@ -128,26 +135,51 @@ embed_user2016("Forty-years-of-S") ### Box -To share a video on Box, the video file itself will have to be shared. From the Box web-interface, you can do this by clicking the **Share** button at the top-right corner of your file's web-page. Then create a **Share Link**: +To share a video on Box, the video file itself will have to be shared. From the Box web-interface, you can do this by clicking the **Share** button at the top-right corner of your file's web-page. +Then create a **Share Link**: ```{r out.width="100%", echo=FALSE} knitr::include_graphics("figures/box-binford.png") ``` -Then, you need to capture some information about the embed-link itself, either the URL or the `id`. Please note that you need to work with the "ugly" URL, not a custom URL: +Then, you need to capture some information about the embed-link itself, either the URL or the `id`. +Please note that you need to work with the "ugly" URL, not a custom URL: ```{r} suggest_embed("https://app.box.com/s/d75g9cr27s2jnx62b86idpgffzzxfdt2") ``` -You can do the same thing using the `embed_box()` function and the `id`. The Box identifier is the last part of the path. +You can do the same thing using the `embed_box()` function and the `id`. +The Box identifier is the last part of the path, in this case **`d75g9cr27s2jnx62b86idpgffzzxfdt2`**. ```{r} embed_box("d75g9cr27s2jnx62b86idpgffzzxfdt2") ``` -If you are using a corporate instance of Box, and use the `embed_box()` function, you will also have to specify the `custom_domain`. For example, if your URL starts with `"https://acme.app.box.com"`, then your `custom_domain` is `"acme"`. +If you are using a corporate instance of Box, and use the `embed_box()` function, you will also have to specify the `custom_domain`. +For example, if your URL starts with `"https://acme.app.box.com"`, then your `custom_domain` is `"acme"`. + +### Microsoft Stream + +Microsoft Stream is a service offered for use by (large) organizations so that they may share videos internally to their organization. +As such, this functionality may have limited appeal. + +```{r} +suggest_embed( + "https://web.microsoftstream.com/video/ae21b0ac-4a2b-41f4-b3fc-f1720dd20f48" +) +``` + +The identifier is the last part of the path of the URL, in this case **`ae21b0ac-4a2b-41f4-b3fc-f1720dd20f48`**. + +```{r} +embed_msstream("ae21b0ac-4a2b-41f4-b3fc-f1720dd20f48") %>% + use_rounded() %>% + use_start_time(10) +``` + +Because this video is internal to an organization, it will likely not play for you. ## Sample videos diff --git a/vignettes/vembedr.Rmd b/vignettes/vembedr.Rmd index b2298c6..24bc802 100644 --- a/vignettes/vembedr.Rmd +++ b/vignettes/vembedr.Rmd @@ -35,6 +35,7 @@ Using `embed_url()`, you can create an embed object for any of these supported s - Vimeo: `embed_vimeo()` - Microsoft Channel 9: `embed_channel9()` - Box: `embed_box()` +- Microsoft Stream: `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: