Skip to content

Commit

Permalink
fix clip transitions when they are not time-ordered v0.20.0
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondben committed Oct 14, 2023
1 parent c9380b9 commit 3d3828b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ovideo
Title: Volleyball Video Utilities
Version: 0.19.7
Version: 0.20.0
Authors@R: c(person(given = "Ben", family = "Raymond", role = c("aut", "cre"), email = "[email protected]"),
person(given = "Adrien", family = "Ickowicz", role = "aut"),
person("openvolley.org", role = "org"))
Expand Down
5 changes: 4 additions & 1 deletion R/playlists.R
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@ match_id_from_meta <- function(z) {

add_seamless_timings <- function(x) {
x <- mutate(x, end_time = .data$start_time + .data$duration)
x <- mutate(group_by(x, .data$video_src), overlap = .data$start_time <= lag(.data$end_time),
x <- mutate(group_by(x, .data$video_src),
## a clip overlaps with its preceding one if the start time of clip i sits within the time period of clip (i-1)
## but if clip i starts *before* clip (i-1) then they do not overlap (cannot be played seamlessly) - maybe a randomly-ordered playlist
overlap = dplyr::n() > 1 & .data$start_time <= lag(.data$end_time) & .data$start_time > lag(.data$start_time),
overlap = case_when(is.na(.data$overlap) ~ FALSE, TRUE ~ .data$overlap), ## TRUE means that this event overlaps with previous
## may be better to calculate overlap in terms of point_id and/or team_touch_id?
seamless_start_time = pmin(.data$video_time, case_when(is.na(lag(.data$end_time)) ~ .data$start_time, TRUE ~ (lag(.data$end_time) + .data$start_time)/2)),
Expand Down
2 changes: 1 addition & 1 deletion inst/extdata/js/vid.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ function dvjs_video_manage() {
if (this_seamless && dvjs_video_controller.current >= 0 && dvjs_video_controller.current < (dvjs_video_controller.queue.length - 1)) {
var item = dvjs_video_controller.queue[dvjs_video_controller.current];
var next_item = dvjs_video_controller.queue[dvjs_video_controller.current+1];
this_seamless = item.video_src == next_item.video_src && next_item.start_time <= (item.start_time + item.duration)
this_seamless = item.video_src == next_item.video_src && next_item.start_time <= (item.start_time + item.duration) && next_item.start_time > item.start_time;
}
dvjs_video_next(this_seamless)
} else {
Expand Down
2 changes: 1 addition & 1 deletion inst/extdata/js/vid2.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ function dvjs_controller(id, type, seamless = true) {
if (this_seamless && that.video_controller.current >= 0 && that.video_controller.current < (that.video_controller.queue.length - 1)) {
var item = that.video_controller.queue[that.video_controller.current];
var next_item = that.video_controller.queue[that.video_controller.current+1];
this_seamless = item.video_src == next_item.video_src && next_item.start_time <= (item.start_time + item.duration);
this_seamless = item.video_src == next_item.video_src && next_item.start_time <= (item.start_time + item.duration) && next_item.start_time > item.start_time;
}
that.video_next(this_seamless);
} else {
Expand Down

0 comments on commit 3d3828b

Please sign in to comment.