ov_playlist_as_onclick | R Documentation |
Convert playlist to 'onclick' string
ov_playlist_as_onclick(
playlist,
video_id,
normalize_paths = TRUE,
dvjs_fun = "dvjs_set_playlist_and_play",
seamless = TRUE,
loop = FALSE,
controller_var
)
playlist |
data.frame: a playlist as returned by |
video_id |
string: the id of the HTML video element to attach the playlist to |
normalize_paths |
logical: if |
dvjs_fun |
string: the javascript function to use |
seamless |
logical: if clips overlap, should we transition seamlessly from one to the next? |
loop |
logical: should we loop endlessly over the playlist? |
controller_var |
string: (for version 2 only) the js variable name of the controller object to assign this playlist to |
A string suitable for inclusion as an 'onclick' tag attribute
## Not run:
library(shiny)
## hand-crafted playlist for this example
playlist <- data.frame(video_src = "NisDpPFPQwU",
start_time = c(624, 3373, 4320),
duration = 8,
type = "youtube")
shinyApp(
ui = fluidPage(
ov_video_js(youtube = TRUE),
ov_video_player(id = "yt_player", type = "youtube",
style = "height: 480px; background-color: black;"),
tags$button("Go", onclick = ov_playlist_as_onclick(playlist, "yt_player"))
),
server = function(input, output) {},
)
## or using v2, which supports multiple video elements in a page
shinyApp(
ui = fluidPage(
ov_video_js(youtube = TRUE, version = 2),
## first player
ov_video_player(id = "yt_player", type = "youtube",
style = "height: 480px; background-color: black;",
version = 2, controller_var = "my_dv"),
tags$button("Go", onclick = ov_playlist_as_onclick(playlist, "yt_player",
controller_var = "my_dv")),
## second player
ov_video_player(id = "yt_player2", type = "youtube",
style = "height: 480px; background-color: black;",
version = 2, controller_var = "my_dv2"),
tags$button("Go", onclick = ov_playlist_as_onclick(playlist, "yt_player2",
controller_var = "my_dv2"))
),
server = function(input, output) {},
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.