install.packages("ovideo", repos = c("https://openvolley.r-universe.dev",
"https://cloud.r-project.org"))
## or
## install.packages("remotes") ## if needed
remotes::install_github("openvolley/ovideo")
Create a standalone HTML file that plays a video playlist.
Start by loading our scout file, which is bundled with the ovdata
package.
library(ovdata) ## install via install.packages("ovdata", repos = c("https://openvolley.r-universe.dev", "https://cloud.r-project.org"))
library(ovideo)
x <- ovdata_example("190301_kats_beds-clip", as = "parsed")
We need to make sure that the video metadata element points somewhere meaningful. We can either use a local video file as the source:
dv_meta_video(x) <- ovdata_example_video("190301_kats_beds")
But if we use a local video file, we can’t share the resulting HTML file with anyone else. Instead we can use an online video URL, in this case on YouTube:
dv_meta_video(x) <- "https://youtu.be/4YH89aSlc6M"
And now on with the rest of the process:
## extract the plays
px <- datavolley::plays(x)
## it's a single rally, so we'll use all rows (just exclude NA skill rows)
px <- px[!is.na(px$skill), ]
## define columns to show in the table
extra_cols <- c("home_team", "visiting_team", "video_time", "code", "set_number",
"home_team_score", "visiting_team_score")
## make the playlist with extra columns included
ply <- ov_video_playlist(px, x$meta, extra_cols = c(extra_cols, "player_name"))
## use player name as the subtitle
ply$subtitle <- ply$player_name
## convert to HTML
f <- ov_playlist_to_html(ply, table_cols = extra_cols)
## and finally open it!
browseURL(f)
And you should see something like: