Skip to contents

Video player tag element

Usage

ov_video_player(
  id,
  type,
  controls = FALSE,
  version = 1,
  controller_var = paste0(id, "_controller"),
  with_js = FALSE,
  ...
)

Arguments

id

string: the id of the tag

type

string: either "youtube", "twitch" (only with version = 2), or "local"

controls

logical: if TRUE, add "previous", "next", "pause", "stop", and "fullscreen" buttons. If controls is an object of class shiny.tag (created by htmltools::tags()) or shiny.tag.list (htmltools::tagList()) then those controls will added with this tag or tag list appended

version

numeric: code version. Default = 1, sort-of-experimental = 2. Version 2 supports multiple players on a single page, as well as type = "twitch"

controller_var

string: (for version 2 only) the js variable name to use for the controller object that controls this video player

with_js

logical: if TRUE, also include the supporting javascript libraries. If with_js = FALSE, you must make a separate call to ov_video_js() (e.g. in your Shiny ui.R function)

...

: other attributes of the player element (passed to the player tags$div call for youtube/twitch or tags$video for local)

Value

HTML tags. The outermost element is a div with id paste0(id, "_container"), with the player and optionally buttons nested within it.

Examples

if (FALSE) {
  library(shiny)

  ## hand-crafted playlist for this example
  playlist <- data.frame(video_src = "NisDpPFPQwU",
                         start_time = c(589, 1036, 1163, 2731, 4594),
                         duration = 8,
                         type = "youtube")

  shinyApp(
      ui = fluidPage(
          ov_video_js(youtube = TRUE, version = 2),
          ov_video_player(id = "yt_player", type = "youtube",
                          version = 2, controller_var = "my_dv",
                          style = "height: 480px; background-color: black;",
                          controls = tags$button("Go",
                                     onclick = ov_playlist_as_onclick(playlist, "yt_player",
                                                                      controller_var = "my_dv")))
      ),
      server = function(input, output) {},
  )
}