ijlyttle / vembedr Goto Github PK
View Code? Open in Web Editor NEWFunctions to Embed Video in HTML
Home Page: https://ijlyttle.github.io/vembedr
License: Other
Functions to Embed Video in HTML
Home Page: https://ijlyttle.github.io/vembedr
License: Other
I think our default should be to embed using defaults:
height = 300
width = NULL
ratio = c("16by9", "4by3")
For the
<iframe/>
itself, we need the width and height, but we can calculate this if we have two of the three values - if we have all three, we ignoreratio
.This begs an internal function:
get_width_height <- function(width, height, ratio) { # validate ratio if (is.null(width) && is.null(height)) { stop() # no can do } if (is.null(width)) { width <- round(height * ratio) } if (is.null(height)) { height <- round(width / ratio) } list(width = width, height = height) }
Source : #33 (comment)
>args(embed_youtube)
function (id, width = NULL, height = 300, ratio = c("16by9",
"4by3"), frameborder = 0, allowfullscreen = TRUE, query = NULL)
NULL
<environment: R_GlobalEnv>
>
>lib('vembedr'); vlist <- c('C1hrbXlreY4', 'O8qPQNz8Q8Y', '3pnXMEusQCY', 'E9_eAm2tTns', 'budv9DSiuko')
>
> embed_youtube(vlist[1], height='auto')
Error in height * ratio : 二进列运算符中有非数值参数
>
> embed_youtube(vlist[1], width='auto')
错误: width is not a number (a length one numeric vector).
>
> embed_youtube(vlist[1], width='auto', height='auto')
错误: width is not a number (a length one numeric vector).
How to make the embed video auto-resize when the browser screen width/height resize.
With regards rmarkdown
, let say embed multiple videos by html
as below, there can be ordered in one line...
<iframe width="560" height="315" src="https://www.youtube.com/embed/O8qPQNz8Q8Y" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> <iframe width="560" height="315" src="https://www.youtube.com/embed/O8qPQNz8Q8Y" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
but use vembedr
on rmarkdown
...
https://getbootstrap.com/docs/3.3/components/#responsive-embed
Maybe this goes into bsplus?
For example:
<blockquote class="tiktok-embed" cite="" data-video-id="6816517532267121925" style="max-width: 605px;min-width: 325px;" >
<section>
</section>
</blockquote>
<script async src="https://www.tiktok.com/embed.js"></script>
Maybe:
use_start_time()
, use_rickroll()
, ...)A silly question, where am I supposed to put the div
tag
if I do this, it is working well on ioslides
(and actually centered)
```{r, echo=FALSE}
library("vembedr")
suppressPackageStartupMessages(library("dplyr"))
embed_youtube("8SGif63VW6E")
This doesn't work, might do something stupid
```{r, echo=FALSE}
div(align = 'center', embed_youtube("8SGif63VW6E"))
same if outside any r chunk
ask Joe and Dean about this- in this package, I am not using the proper htmltools API to set, rather than to append tag attributes.
these were deprecated in 0.1.5, now it's time to get rid of them
replace Travis
MS Stream, for example (#38)
embed_user2016 is a specific case of this.
perhaps id can be a vector argument, specifying the path
I think our default should be to embed using defaults:
height = 300
width = NULL
ratio = c("16by9", "4by3")
For the <iframe/>
itself, we need the width and height, but we can calculate this if we have two of the three values - if we have all three, we ignore ratio
.
This begs an internal function:
get_width_height <- function(width, height, ratio) {
# validate ratio
if (is.null(width) && is.null(height)) {
stop() # no can do
}
if (is.null(width)) {
width <- round(height * ratio)
}
if (is.null(height)) {
height <- round(width / ratio)
}
list(width = width, height = height)
}
thanks for this package Ian!
when trying your example, nothing is displayed when knitting in rstudio.
Once opened in a regular browser, it works as expected.
git_default_branch_rename(from = NULL, to = "main")
I know I have this somewhere, but it will need to be generalized
Prepare for release:
devtools::build_readme()
devtools::check(remote = TRUE, manual = TRUE)
devtools::check_win_devel()
rhub::check_for_cran()
revdepcheck::revdep_check(num_workers = 4)
cran-comments.md
Submit to CRAN:
usethis::use_version('patch')
devtools::submit_cran()
Wait for CRAN...
usethis::use_github_release()
usethis::use_dev_version()
no idea if this is feasible, but could we have an option to have an iframe with rounded corners?
that would fit better ioslides
a relevant link on StackOverflow
Would have to wait for usethis to go again to CRAN.
Although, we could use the trick of testing for the namespace and the version.
use testthat 3e
align tests better with functions
How to play video programmatically when user push some buttom ?
the installation instructions say install.packages("dplyr")
but should say install.packages("vembedr")
e.g.:
<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/434868702&color=ff5500&hide_related=true"></iframe>
although it does on shinyapps.io
2016/06/20 17:47:50.379050426 Installing vembedr (0.1.0) ...
2016/06/20 17:47:56.845528191 FAILED
2016/06/20 17:47:56.850158165 Error in getSourceForPkgRecord(pkgRecord, srcDir(project), availablePkgs, : Couldn't find source for version 0.1.0 of vembedr
2016/06/20 17:47:56.850262867
2016/06/20 17:47:56.850275012 Unable to fully restore the R packages associated with this deployment.
2016/06/20 17:47:56.850278262 Please review the preceding messages to determine which package
2016/06/20 17:47:56.850283760 encountered installation difficulty and the cause of the failure.
2016/06/20 17:47:56.850285955
2016/06/20 17:47:56.850291018 Some typical reasons for package installation failures:
2016/06/20 17:47:56.850292936 * A system library needed by the R package is not installed.
2016/06/20 17:47:56.872321342 Some of the most common package dependencies are cataloged at:
2016/06/20 17:47:56.872345080 https://github.com/rstudio/shinyapps-package-dependencies
2016/06/20 17:47:56.872347788 * The R package is Windows-only or otherwise unavailable for this
2016/06/20 17:47:56.872353666 operating system.
2016/06/20 17:47:56.872355736 * The package is housed in a private repository that requires
2016/06/20 17:47:56.872360934 authentication to access. For more details on this, see:
2016/06/20 17:47:56.872362822 rstudio/packrat#270
2016/06/20 17:47:56.872374727
2016/06/20 17:47:56.872376812 Please contact your RStudio Connect administrator for further help
2016/06/20 17:47:56.872397952 resolving this issue.
2016/06/20 17:47:57.177825114 Warning message:
2016/06/20 17:47:57.177836981 In packrat::restore(overwrite.dirty = TRUE, prompt = FALSE, restart = FALSE) :
2016/06/20 17:47:57.177847025 The most recent snapshot was generated using R version 3.3.0
example:
<iframe src="https://cloud.app.box.com/embed/s/yvslpsbq3rq1pqz0spqxr8sh62fe5hn9" width="708" height="458" frameborder="0" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen" msallowfullscreen=""></iframe>
more generally:
<iframe src="https://{custom_domain}.app.box.com/embed/s/{shared link value}?view={list or icon}&sortColumn={name, date, or size}&sortDirection=ASC" width="{pixels}" height="{pixels}" frameborder="0" allowfullscreen webkitallowfullscreen msallowfullscreen></iframe>
The video embedded here:
https://app.box.com/s/m5do45hvzw32iv2aors3urf5pgkxxazx
references:
Thanks to a kind twitter DM:
Emdebbing -> Embedding
Will need to import httr
@tungmilan sent along this code (thanks!) for embedding a local file:
<iframe width="720" height="480" src="`r video_files[1]`" frameborder="0" allowfullscreen align="center"></iframe>
Prepare for release:
devtools::build_readme()
urlchecker::url_check()
devtools::check(remote = TRUE, manual = TRUE)
devtools::check_win_devel()
rhub::check_for_cran()
revdepcheck::revdep_check(num_workers = 4)
cran-comments.md
Submit to CRAN:
usethis::use_version('patch')
devtools::submit_cran()
Wait for CRAN...
usethis::use_github_release()
usethis::use_dev_version()
hms()
interferes with hms package
use_start_time()
is the public function
From the README
It seems that Vimeo does not provide the option to specify a start time.
Actually, Vimeo does. Just use #at=<seconds>
to indicate start time.
This is what my work is using now to share videos internally: https://web.microsoftstream.com/
embed_foo()
functions vs. helper functions (like use_start_time()
)hms()
In anticipation of a CRAN release:
@inheritParams use_start_time()
and @inherit embed return
embed_url("https://youtu.be/1-vcErOPofQ?t=28s") starts at 28s
Full url
embed_url("https://www.youtube.com/watch?v=1-vcErOPofQ&feature=youtu.be?t=28s") starts at beginning
The README would look so much better with a little bling...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.