-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
- Loading branch information
Showing
24 changed files
with
236 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,40 @@ | ||
#' 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`** | ||
#' | ||
#' - 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`** | ||
#' | ||
#' @name vembedr-s3-classes | ||
#' | ||
NULL | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.