ov_video_playlist: Create video playlist

View source: R/playlists.R

ov_video_playlistR Documentation

Create video playlist

Description

Create video playlist

Usage

ov_video_playlist(
  x,
  meta,
  type = NULL,
  timing = ov_video_timing(),
  extra_cols = NULL,
  normalize_paths = TRUE
)

Arguments

x

data.frame: a datavolleyplays object. Normally this will be a selected subset of the plays component of a datavolley object (i.e. a selected set of actions that you want the video playlist to contain)

meta

list: either the meta component of a datavolley object, or a list of such objects, or a data.frame with the columns "match_id" and "video_src". Entries in video_src should be paths or URLs to the video file associated with the corresponding match_id

type

string: currently "youtube", "twitch", or "local". If type is not specified as a parameter, and meta is a data.frame, then type can be provided as a column in meta. Alternatively, if meta is a meta component of a datavolley object, or a list of such objects, then type will be assumed to be "local". Note that a single playlist can't mix types, all entries must be of the same type

timing

list: the relative timing for each skill type, either a named list as returned by ov_video_timing() or a data.frame as returned by ov_video_timing_df(). See ov_video_timing() for further details

extra_cols

character: names of additional columns from x to include in the returned data frame

normalize_paths

logical: if TRUE, apply normalizePath to local file paths. This will e.g. expand the tilde in paths like "~/path/to/video.mp4"

Value

A data.frame with columns src, start_time, duration, plus any extras specified in extra_cols

Examples

## read data file
x <- datavolley::dv_read(datavolley::dv_example_file())
## note that this data file has no video specified, so put a dummy value in
dv_meta_video(x) <- "c:\\my_video.mp4"

## extract play-by-play data
px <- datavolley::plays(x)
## and put dummy video_time values in, because those are missing too
px$video_time <- sample.int(2e3, size = nrow(px))

## find pipe (XP) attacks in transition
px <- px[which(px$attack_code == "XP" & px$phase == "Transition"), ]

## create playlist
ply <- ov_video_playlist(px, x$meta, timing = ov_video_timing())

## with custom timing
ply <- ov_video_playlist(px, x$meta,
  timing = ov_video_timing_df(data.frame(skill = "Attack", phase = "Transition",
                              start_offset = -5, duration = 10, stringsAsFactors = FALSE)))


openvolley/ovideo documentation built on March 19, 2024, 9:52 p.m.