Skip to content

feat: add video duration-based pricing via HTML5 File API#110

Open
RensTillmann wants to merge 1 commit intomasterfrom
claude/issue-104-20260326-2244
Open

feat: add video duration-based pricing via HTML5 File API#110
RensTillmann wants to merge 1 commit intomasterfrom
claude/issue-104-20260326-2244

Conversation

@RensTillmann
Copy link
Copy Markdown
Owner

Description

Allows calculator fields to use {fieldname;duration} syntax to sum total video duration (seconds) of uploaded files before submission. Uses HTML5 File API with a hidden <video> element to read metadata without uploading.

Closes #104

Target Branch

  • master

Super Forms Version

Targets version: v6.4.201

User Population Affected

  • Add-on users only — add-on name: Calculator / File Upload

Type of Change

  • New feature (non-breaking)

Backward Compatibility Checklist

  • No super_* hook or filter name was renamed or removed
  • No [super_form] shortcode attribute was removed or renamed
  • No Action Scheduler hook name was changed

For AI-Generated PRs

Source issue: #104
Implementation confidence: uncertain
Files modified: src/assets/js/common.js
New hooks added (if any): none
Migration required: no

Allow calculator fields to use {fieldname;duration} syntax to sum the
total duration (in seconds) of uploaded video files before submission.

When a video file is selected, a temporary blob URL is created and loaded
into a hidden <video> element. The duration is read from the
loadedmetadata event and stored in SUPER.files, then the calculator hook
is re-triggered to update pricing in real time.

Usage example: {video_field;duration} * 5.00 prices at $5 per second.

Closes #104

Co-authored-by: Rens Tillmann <RensTillmann@users.noreply.github.com>
var fileList = SUPER.files[uploadFormId][name];
for (var fli = 0; fli < fileList.length; fli++) {
if (fileList[fli] && typeof fileList[fli]['duration'] !== 'undefined') {
sum += parseFloat( fileList[fli]['duration'] );
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['duration'] is better written in dot notation.

typeof SUPER.files[uploadFormId][name] !== 'undefined') {
var fileList = SUPER.files[uploadFormId][name];
for (var fli = 0; fli < fileList.length; fli++) {
if (fileList[fli] && typeof fileList[fli]['duration'] !== 'undefined') {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

['duration'] is better written in dot notation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant