Skip to content

Instantly share code, notes, and snippets.

@schochastics
Last active February 1, 2024 13:55
Show Gist options
  • Save schochastics/5c5b2d153625c7e2e8bcf3ea7e874c3a to your computer and use it in GitHub Desktop.
Save schochastics/5c5b2d153625c7e2e8bcf3ea7e874c3a to your computer and use it in GitHub Desktop.
Play youtube videos in Rstudio viewer pane
library(shiny)
xy <- c(784,479) #output of grDevices::dev.size("px")
url <- "https://www.youtube.com/watch?v=Ef2jmf2vy00" #copy yt link here
url <- gsub("watch\\?v=","embed/",url)
ui <- fluidPage(
HTML(paste0('<iframe width="',xy[1],'" height="',xy[2],'" src="',url,'" frameborder="0"></iframe>'))
)
server <- function(input, output, session) {
}
runGadget(shinyApp(ui, server,options=c("launch.browser"=FALSE,"port"=1111)),port=1111,viewer = paneViewer())
@schochastics
Copy link
Author

schochastics commented Feb 19, 2021

  • change the url to yt video of choice
  • source the file as a local job in Rstudio.
  • close the browser window that pops up
  • run rstudioapi::viewer("http://127.0.0.1:1111") in the R console
  • watch video and code

rstudio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment