Git Product home page Git Product logo

vembedr's Introduction

vembedr

CRAN_Status_Badge R-CMD-check

The goal of vembedr is to make it a little bit easier for you to embed videos into your RMarkdown documents and your Shiny apps; these services are supported:

  • YouTube
  • Vimeo
  • Box
  • Microsoft Stream

New to version 0.1.5

  • updated internal implementation to comport with latest Pandoc. (#52, thanks @jnolis!)
  • deprecated Microsoft Channel 9 (including UserR! 2016 & 2017), as Channel 9 has been moved. (#54)

Installation

You can install the latest released version from CRAN with:

install.packages("vembedr")

or the latest development version from GitHub with:

# install.packages("devtools")
devtools::install_github("ijlyttle/vembedr")

Documentation

This project supports two documentation-websites, built using pkgdown:

Usage

The most useful function might be embed_url(). If the URL is from one of the supported services, it will do the right thing:

library("vembedr")

embed_url("https://www.youtube.com/watch?v=uV4UpCq2azs")

The video is not embedded in this README file as is rendered to Markdown; to see embedded videos, please see vignette("vembedr"). Each of the supported services, e.g. YouTube, is discussed in vignette("embed").

The functions are designed to be piped. For example, here’s how you can modify the appearance and the start time:

embed_url("https://www.youtube.com/watch?v=uV4UpCq2azs") %>%
  use_start_time("1m32") %>%
  use_align("center")

To see these functions in action, see vignette("modify").

Caveats

  • Be aware that, due to licensing issues, not all videos will play when embedded at a different site (like your HTML document).

  • The RStudio viewer will embed YouTube and Vimeo videos, but not others. Videos from all services should be rendered as you expect in a browser like Chrome.

  • Some of the formatting, e.g. rounded corners, does not render on mobile sites.

Code of Conduct

Please note that the vembedr project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

vembedr's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vembedr's Issues

support SoundCloud

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&amp;color=ff5500&amp;hide_related=true"></iframe>

Document

In anticipation of a CRAN release:

  • check for videos that do not play "freely" anymore
  • organize the references in pkgdown
  • make sure we are using @inheritParams use_start_time() and @inherit embed return
  • articles for embed, use, and get-started
  • rework readme
  • draft a blog post

embed_youtube(width = 'auto', height = 'auto')

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)
}

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).

Raised Issue for Enhancement

  1. How to make the embed video auto-resize when the browser screen width/height resize.

  2. 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...

Screenshot_4

support Box videos

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:

Vimeo start time support

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.

specify aspect-ratio

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)
}

video not displayed in rstudio' browser

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.

Release vembedr 0.1.4

  • clean up documentation

Prepare for release:

  • devtools::build_readme()
  • Check current CRAN check results
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • revdepcheck::revdep_check(num_workers = 4) no reverse dependencies
  • Update cran-comments.md
  • Polish NEWS

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()

where to insert div() in ioslides_presentation

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

Release vembedr 1.5.0

Prepare for release:

  • Check current CRAN check results
  • Polish NEWS
  • 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)
  • Update cran-comments.md
  • Review pkgdown reference index for, e.g., missing topics
  • Draft blog post

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

rounded frame

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

Split the vignettes

Maybe:

  • brief summary
  • each of the video services (YouTube, Vimeo, ...)
  • helper functions (use_start_time(), use_rickroll(), ...)

things to do before next CRAN submission

  • talk about philosophy of embed_foo() functions vs. helper functions (like use_start_time())
  • talk about vagaries of start time for Vimeo and Channel 9
  • document & test hms()
  • examine test coverage
  • update vignette, readme, gh-pages
  • usual "Tidyverse" checklist (bump version, NEWS, tag, etc.)

tiktok

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>

clean up for CRAN

thanks to #52, would like to get things out to CRAN asap - some cleanup to get to:

  • use new pkgdown I'll do this later...
  • take care of link-rot in pkgdown site (done in #57)

Play video

How to play video programmatically when user push some buttom ?

package does not load on beta.rstudioconnect.com

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

Embed local file

@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>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.