video

Lifecycle: experimental Codecov test coverage R-CMD-check

{video} - Interactive Video Player

{video} is a package that utilises the video.js library to play video on the modern web.

Installation

This package is not yet available on CRAN. To install the latest version:

install.packages("devtools")
devtools::install_github("ashbaldry/video")

Usage

The HTML way to include an audio file in any shiny application/web page is to use the <audio> tag. This cannot (easily) be manipulated from the server.

tags$video(src = "https://vjs.zencdn.net/v/oceans.mp4", type = "video/mp4", controls = NA)

video.js is a flexible video player that is more robust than the basic HTML5 video player, and can easily be manipulated from the server side of shiny applications.

library(shiny)
library(video)

ui <- fluidPage(
  title = "video Example",
  h1("Video Example"),
  video(
    "https://vjs.zencdn.net/v/oceans.mp4",
    elementId = "video"
  ),
  tags$p(
    "Currently playing:",
    textOutput("video_playing", container = tags$strong, inline = TRUE)
  )
)

server <- function(input, output, session) {
  output$video_playing <- renderText({
    if (isTRUE(input$video_playing)) "Yes" else "No"
  })

  observe({
    req(input$video_seek)
    if (round(input$video_seek) == 10) {
      pauseVideo("video")
    } else if (round(input$video_seek) == 20) {
      stopVideo("video")
    }
  })
}

shinyApp(ui, server)