Skip to content

Feature/add video duration condition #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ public abstract class BaseExpression<T extends BaseExpression> {
"currentPage", "cp",
"tags", "tags",
"pageX", "px",
"pageY", "py"
"pageY", "py",
"duration","du",
"initial_duration","idu",
"initialDuration","idu"

);
private static final Pattern PATTERN = getPattern();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ public Condition height(String operator, Object value) {
public Condition aspectRatio(String operator, Object value) {
return predicate("ar", operator, value);
}
public Condition duration(String operator, Object value) {
return predicate("du", operator, value);
}
public Condition initialDuration(String operator, Object value) {
return predicate("idu", operator, value);
}


/**
* @deprecated Use {@link #faceCount(String, Object)} instead
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ public void ifElse() throws Exception {
assertEquals("if_else should be without any transformation parameters", "if_w_lt_200/c_fill,h_120,w_80/if_else/c_fill,h_90,w_100", transformation.toString());
}

@Test
public void testDuration() throws Exception {
Transformation transformation = new Transformation().ifCondition().duration("gt", "30").then().width(100).crop("scale");
assertEquals("passing an operator and a value adds a condition", "if_du_gt_30,c_scale,w_100", transformation.toString());
transformation = new Transformation().ifCondition().initialDuration("gt", "30").then().width(100).crop("scale");
assertEquals("passing an operator and a value adds a condition", "if_idu_gt_30,c_scale,w_100", transformation.toString());
transformation=new Transformation().ifCondition("initialDuration > 20").crop("scale").width(200);
assertEquals("if_idu_gt_20,c_scale,w_200", transformation.generate());
}


@Test
public void chainedConditions() throws Exception {
Transformation transformation = new Transformation().ifCondition().aspectRatio("gt", "3:4").then().width(100).crop("scale");
Expand Down