canvas-recorder-lib 0.8.1 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -2
- package/dev/canvas-recorder.css +20 -6
- package/dev/canvas-recorder.ts +389 -54
- package/dev/color-picker.ts +13 -0
- package/dev/component-picker.ts +60 -11
- package/dev/delay-files.ts +3 -1
- package/dev/font-widgets.ts +2 -2
- package/dev/format-editor.ts +3 -1
- package/dev/fourier-panel.ts +7 -3
- package/dev/handwriting-panel.ts +7 -7
- package/dev/multi-text-dialog.ts +28 -15
- package/dev/player-body.ts +78 -33
- package/dev/schedule-helpers.ts +10 -3
- package/dev/static-image-panel.ts +4 -4
- package/dev/subtitles.ts +170 -0
- package/dev/synced-file.ts +34 -0
- package/dev/timeline-display.ts +1 -1
- package/dev/transcribe-core.ts +7 -4
- package/dev/transcript-align.ts +24 -18
- package/dev/transcript-editor.ts +1187 -0
- package/dev/transcript-export.ts +90 -0
- package/dev/transcript-view.ts +8 -5
- package/dev/transcripts.ts +140 -15
- package/dev/video-clip-panel.ts +4 -4
- package/dist/dev/canvas-recorder.css +20 -6
- package/dist/dev/canvas-recorder.js +314 -48
- package/dist/dev/canvas-recorder.js.map +1 -1
- package/dist/dev/color-picker.d.ts.map +1 -1
- package/dist/dev/color-picker.js +15 -0
- package/dist/dev/color-picker.js.map +1 -1
- package/dist/dev/component-picker.d.ts +2 -1
- package/dist/dev/component-picker.d.ts.map +1 -1
- package/dist/dev/component-picker.js +56 -11
- package/dist/dev/component-picker.js.map +1 -1
- package/dist/dev/delay-files.d.ts.map +1 -1
- package/dist/dev/delay-files.js +3 -1
- package/dist/dev/delay-files.js.map +1 -1
- package/dist/dev/font-widgets.d.ts +2 -2
- package/dist/dev/font-widgets.d.ts.map +1 -1
- package/dist/dev/font-widgets.js.map +1 -1
- package/dist/dev/format-editor.d.ts.map +1 -1
- package/dist/dev/format-editor.js +3 -1
- package/dist/dev/format-editor.js.map +1 -1
- package/dist/dev/fourier-panel.d.ts.map +1 -1
- package/dist/dev/fourier-panel.js +4 -3
- package/dist/dev/fourier-panel.js.map +1 -1
- package/dist/dev/handwriting-panel.d.ts +4 -4
- package/dist/dev/handwriting-panel.d.ts.map +1 -1
- package/dist/dev/handwriting-panel.js.map +1 -1
- package/dist/dev/multi-text-dialog.d.ts.map +1 -1
- package/dist/dev/multi-text-dialog.js +23 -12
- package/dist/dev/multi-text-dialog.js.map +1 -1
- package/dist/dev/player-body.d.ts +1 -1
- package/dist/dev/player-body.d.ts.map +1 -1
- package/dist/dev/player-body.js +78 -33
- package/dist/dev/player-body.js.map +1 -1
- package/dist/dev/schedule-helpers.d.ts.map +1 -1
- package/dist/dev/schedule-helpers.js +4 -2
- package/dist/dev/schedule-helpers.js.map +1 -1
- package/dist/dev/static-image-panel.d.ts +3 -3
- package/dist/dev/static-image-panel.d.ts.map +1 -1
- package/dist/dev/subtitles.d.ts +36 -0
- package/dist/dev/subtitles.d.ts.map +1 -0
- package/dist/dev/subtitles.js +135 -0
- package/dist/dev/subtitles.js.map +1 -0
- package/dist/dev/synced-file.d.ts +14 -0
- package/dist/dev/synced-file.d.ts.map +1 -1
- package/dist/dev/synced-file.js +22 -0
- package/dist/dev/synced-file.js.map +1 -1
- package/dist/dev/timeline-display.d.ts +5 -0
- package/dist/dev/timeline-display.d.ts.map +1 -1
- package/dist/dev/timeline-display.js +1 -1
- package/dist/dev/timeline-display.js.map +1 -1
- package/dist/dev/transcribe-core.d.ts.map +1 -1
- package/dist/dev/transcribe-core.js +7 -4
- package/dist/dev/transcribe-core.js.map +1 -1
- package/dist/dev/transcript-align.d.ts +6 -4
- package/dist/dev/transcript-align.d.ts.map +1 -1
- package/dist/dev/transcript-align.js +18 -13
- package/dist/dev/transcript-align.js.map +1 -1
- package/dist/dev/transcript-editor.d.ts +36 -0
- package/dist/dev/transcript-editor.d.ts.map +1 -0
- package/dist/dev/transcript-editor.js +948 -0
- package/dist/dev/transcript-editor.js.map +1 -0
- package/dist/dev/transcript-export.d.ts +21 -0
- package/dist/dev/transcript-export.d.ts.map +1 -1
- package/dist/dev/transcript-export.js +65 -0
- package/dist/dev/transcript-export.js.map +1 -1
- package/dist/dev/transcript-view.d.ts +2 -0
- package/dist/dev/transcript-view.d.ts.map +1 -1
- package/dist/dev/transcript-view.js +1 -1
- package/dist/dev/transcript-view.js.map +1 -1
- package/dist/dev/transcripts.d.ts +18 -1
- package/dist/dev/transcripts.d.ts.map +1 -1
- package/dist/dev/transcripts.js +102 -12
- package/dist/dev/transcripts.js.map +1 -1
- package/dist/dev/video-clip-panel.d.ts +3 -3
- package/dist/dev/video-clip-panel.d.ts.map +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/src/glib/line-font.d.ts +6 -0
- package/dist/src/glib/line-font.d.ts.map +1 -1
- package/dist/src/glib/line-font.js +9 -0
- package/dist/src/glib/line-font.js.map +1 -1
- package/dist/src/glib/path-shape.d.ts +23 -0
- package/dist/src/glib/path-shape.d.ts.map +1 -1
- package/dist/src/glib/path-shape.js +66 -221
- package/dist/src/glib/path-shape.js.map +1 -1
- package/dist/src/glib/svg-arc.d.ts +41 -0
- package/dist/src/glib/svg-arc.d.ts.map +1 -0
- package/dist/src/glib/svg-arc.js +114 -0
- package/dist/src/glib/svg-arc.js.map +1 -0
- package/dist/src/glib/svg-path-parser.d.ts +60 -0
- package/dist/src/glib/svg-path-parser.d.ts.map +1 -0
- package/dist/src/glib/svg-path-parser.js +258 -0
- package/dist/src/glib/svg-path-parser.js.map +1 -0
- package/dist/src/glib/transforms.d.ts +9 -0
- package/dist/src/glib/transforms.d.ts.map +1 -1
- package/dist/src/glib/transforms.js +7 -4
- package/dist/src/glib/transforms.js.map +1 -1
- package/dist/src/interpolate.d.ts +17 -10
- package/dist/src/interpolate.d.ts.map +1 -1
- package/dist/src/interpolate.js +1 -17
- package/dist/src/interpolate.js.map +1 -1
- package/dist/src/morph-animation.js +1 -1
- package/dist/src/morph-animation.js.map +1 -1
- package/dist/src/peano-fourier/fourier-shared.d.ts.map +1 -1
- package/dist/src/peano-fourier/fourier-shared.js +4 -2
- package/dist/src/peano-fourier/fourier-shared.js.map +1 -1
- package/dist/src/schedule-helper.d.ts +50 -28
- package/dist/src/schedule-helper.d.ts.map +1 -1
- package/dist/src/schedule-helper.js +22 -0
- package/dist/src/schedule-helper.js.map +1 -1
- package/dist/src/showable.d.ts +57 -10
- package/dist/src/showable.d.ts.map +1 -1
- package/dist/src/showable.js +19 -0
- package/dist/src/showable.js.map +1 -1
- package/dist/src/slide-components/arrow.d.ts +4 -4
- package/dist/src/slide-components/arrow.d.ts.map +1 -1
- package/dist/src/slide-components/cross-fade-transition.d.ts +2 -1
- package/dist/src/slide-components/cross-fade-transition.d.ts.map +1 -1
- package/dist/src/slide-components/cross-fade-transition.js +2 -1
- package/dist/src/slide-components/cross-fade-transition.js.map +1 -1
- package/dist/src/slide-components/duration-agnostic.d.ts +3 -2
- package/dist/src/slide-components/duration-agnostic.d.ts.map +1 -1
- package/dist/src/slide-components/duration-agnostic.js +4 -2
- package/dist/src/slide-components/duration-agnostic.js.map +1 -1
- package/dist/src/slide-components/fixed-duration.d.ts +3 -1
- package/dist/src/slide-components/fixed-duration.d.ts.map +1 -1
- package/dist/src/slide-components/fixed-duration.js +4 -2
- package/dist/src/slide-components/fixed-duration.js.map +1 -1
- package/dist/src/slide-components/fourier.d.ts +19 -12
- package/dist/src/slide-components/fourier.d.ts.map +1 -1
- package/dist/src/slide-components/fourier.js +77 -16
- package/dist/src/slide-components/fourier.js.map +1 -1
- package/dist/src/slide-components/function-graph.d.ts +4 -3
- package/dist/src/slide-components/function-graph.d.ts.map +1 -1
- package/dist/src/slide-components/function-graph.js +6 -2
- package/dist/src/slide-components/function-graph.js.map +1 -1
- package/dist/src/slide-components/halftone-shadow.d.ts +8 -7
- package/dist/src/slide-components/halftone-shadow.d.ts.map +1 -1
- package/dist/src/slide-components/halftone-shadow.js +14 -10
- package/dist/src/slide-components/halftone-shadow.js.map +1 -1
- package/dist/src/slide-components/handwriting-effect.d.ts +8 -6
- package/dist/src/slide-components/handwriting-effect.d.ts.map +1 -1
- package/dist/src/slide-components/handwriting-effect.js +4 -2
- package/dist/src/slide-components/handwriting-effect.js.map +1 -1
- package/dist/src/slide-components/hold.d.ts +4 -2
- package/dist/src/slide-components/hold.d.ts.map +1 -1
- package/dist/src/slide-components/hold.js +4 -2
- package/dist/src/slide-components/hold.js.map +1 -1
- package/dist/src/slide-components/image.d.ts +7 -7
- package/dist/src/slide-components/image.d.ts.map +1 -1
- package/dist/src/slide-components/image.js +4 -2
- package/dist/src/slide-components/image.js.map +1 -1
- package/dist/src/slide-components/in-parallel.d.ts +6 -3
- package/dist/src/slide-components/in-parallel.d.ts.map +1 -1
- package/dist/src/slide-components/in-parallel.js +12 -2
- package/dist/src/slide-components/in-parallel.js.map +1 -1
- package/dist/src/slide-components/in-series.d.ts +2 -1
- package/dist/src/slide-components/in-series.d.ts.map +1 -1
- package/dist/src/slide-components/in-series.js +2 -1
- package/dist/src/slide-components/in-series.js.map +1 -1
- package/dist/src/slide-components/live-duration.d.ts +3 -1
- package/dist/src/slide-components/live-duration.d.ts.map +1 -1
- package/dist/src/slide-components/live-duration.js +4 -2
- package/dist/src/slide-components/live-duration.js.map +1 -1
- package/dist/src/slide-components/multi-text.d.ts +39 -26
- package/dist/src/slide-components/multi-text.d.ts.map +1 -1
- package/dist/src/slide-components/multi-text.js +44 -29
- package/dist/src/slide-components/multi-text.js.map +1 -1
- package/dist/src/slide-components/rectangle.d.ts +5 -4
- package/dist/src/slide-components/rectangle.d.ts.map +1 -1
- package/dist/src/slide-components/rectangle.js +2 -1
- package/dist/src/slide-components/rectangle.js.map +1 -1
- package/dist/src/slide-components/registry.d.ts +5 -0
- package/dist/src/slide-components/registry.d.ts.map +1 -1
- package/dist/src/slide-components/registry.js +28 -27
- package/dist/src/slide-components/registry.js.map +1 -1
- package/dist/src/slide-components/show-error.d.ts.map +1 -1
- package/dist/src/slide-components/show-error.js +12 -4
- package/dist/src/slide-components/show-error.js.map +1 -1
- package/dist/src/slide-components/simple-text.d.ts +11 -10
- package/dist/src/slide-components/simple-text.d.ts.map +1 -1
- package/dist/src/slide-components/simple-text.js +5 -3
- package/dist/src/slide-components/simple-text.js.map +1 -1
- package/dist/src/slide-components/slide-component.d.ts +14 -13
- package/dist/src/slide-components/slide-component.d.ts.map +1 -1
- package/dist/src/slide-components/slide-component.js +2 -1
- package/dist/src/slide-components/slide-component.js.map +1 -1
- package/dist/src/slide-components/slide-left.d.ts +2 -1
- package/dist/src/slide-components/slide-left.d.ts.map +1 -1
- package/dist/src/slide-components/slide-left.js +2 -1
- package/dist/src/slide-components/slide-left.js.map +1 -1
- package/dist/src/slide-components/text-effect.d.ts +9 -1
- package/dist/src/slide-components/text-effect.d.ts.map +1 -1
- package/dist/src/slide-components/text-effect.js.map +1 -1
- package/dist/src/slide-components/traditional-text.d.ts +8 -8
- package/dist/src/slide-components/traditional-text.d.ts.map +1 -1
- package/dist/src/slide-components/video-clip.d.ts +4 -3
- package/dist/src/slide-components/video-clip.d.ts.map +1 -1
- package/dist/src/slide-components/video-clip.js +2 -1
- package/dist/src/slide-components/video-clip.js.map +1 -1
- package/lib/index.ts +1 -0
- package/package.json +2 -2
- package/src/glib/line-font.ts +9 -0
- package/src/glib/path-shape.ts +101 -245
- package/src/glib/svg-arc.ts +141 -0
- package/src/glib/svg-path-parser.ts +308 -0
- package/src/glib/transforms.ts +7 -4
- package/src/interpolate.ts +18 -27
- package/src/morph-animation.ts +1 -1
- package/src/peano-fourier/fourier-shared.ts +4 -2
- package/src/schedule-helper.ts +50 -28
- package/src/showable.ts +79 -10
- package/src/slide-components/arrow.ts +4 -4
- package/src/slide-components/cross-fade-transition.ts +9 -2
- package/src/slide-components/duration-agnostic.ts +4 -3
- package/src/slide-components/fixed-duration.ts +4 -2
- package/src/slide-components/fourier.ts +98 -29
- package/src/slide-components/function-graph.ts +7 -3
- package/src/slide-components/halftone-shadow.ts +21 -16
- package/src/slide-components/handwriting-effect.ts +8 -6
- package/src/slide-components/hold.ts +18 -4
- package/src/slide-components/image.ts +9 -7
- package/src/slide-components/in-parallel.ts +16 -1
- package/src/slide-components/in-series.ts +3 -1
- package/src/slide-components/live-duration.ts +4 -2
- package/src/slide-components/multi-text.ts +71 -44
- package/src/slide-components/rectangle.ts +6 -4
- package/src/slide-components/registry.ts +33 -27
- package/src/slide-components/show-error.ts +13 -4
- package/src/slide-components/simple-text.ts +22 -12
- package/src/slide-components/slide-component.ts +15 -13
- package/src/slide-components/slide-left.ts +9 -2
- package/src/slide-components/text-effect.ts +9 -0
- package/src/slide-components/traditional-text.ts +8 -8
- package/src/slide-components/video-clip.ts +5 -3
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import "./canvas-recorder.css";
|
|
2
2
|
import { assertNonNullable, FIGURE_SPACE, parseFloatX, } from "phil-lib/misc";
|
|
3
3
|
import { AnimationLoop, getById, querySelector, } from "phil-lib/client-misc";
|
|
4
|
-
import { Output, StreamTarget, CanvasSource, Mp4OutputFormat, AudioBufferSource, QUALITY_HIGH, } from "mediabunny";
|
|
4
|
+
import { Output, StreamTarget, CanvasSource, Mp4OutputFormat, AudioBufferSource, QUALITY_HIGH, TextSubtitleSource, } from "mediabunny";
|
|
5
|
+
import { choiceLabel, propertyLabel, } from "../src/showable.js";
|
|
5
6
|
import { discreteKeyframes, interpolateColors, interpolateLattices, interpolateNumbers, interpolatePoints, interpolateRects, } from "../src/interpolate.js";
|
|
6
7
|
import { Lattice } from "../src/lattice.js";
|
|
8
|
+
import { checkPanAndZoom } from "../src/glib/transforms.js";
|
|
7
9
|
import { interpolateArrow } from "../src/schedule-helper.js";
|
|
8
10
|
import { applyJsonEntry, applyTree, counterparts, fillTreeDefaults, findSerializedNode, isVideoSnapshot, omitComponentDefaults, registryDefault, omitTreeDefaults, serializeComponents, serializeScalars, serializeSchedules, serializeTree, SNAPSHOT_FORMAT_VERSION, } from "../src/snapshot.js";
|
|
9
11
|
import { downloadBlob, philDebug } from "../src/utility.js";
|
|
10
12
|
import { getNewDebugLogEntries } from "../src/debug-log.js";
|
|
11
|
-
import { SAMPLE_RATE, Soundtrack } from "./soundtrack.js";
|
|
13
|
+
import { collectSoundClips, SAMPLE_RATE, Soundtrack } from "./soundtrack.js";
|
|
12
14
|
import { openVoicePanel } from "./voice/voice-panel.js";
|
|
13
15
|
import { openColorPickerDialog } from "./color-picker.js";
|
|
14
16
|
import { setSwatchColor } from "./color-utils.js";
|
|
@@ -20,10 +22,12 @@ import { buildTextFramePanel } from "./multi-text-panel.js";
|
|
|
20
22
|
import { openMultiTextDialog } from "./multi-text-dialog.js";
|
|
21
23
|
import { ownerOf, parseSoundClips, rehomeSoundClip, soundOwners, startWithin, tidyMs, } from "./sound-clips.js";
|
|
22
24
|
import { askHowToSplit, askHowToSplitSound } from "./split-dialog.js";
|
|
23
|
-
import { SyncedFile } from "./synced-file.js";
|
|
25
|
+
import { onSyncStatusChange, SyncedFile, } from "./synced-file.js";
|
|
24
26
|
import { TimelineDisplay, } from "./timeline-display.js";
|
|
25
|
-
import { forgetTranscriptFailures, forgetTranscripts, makeTranscript, onTranscriptsChange, readyTranscript, setTranscriptsEnabled, statusText, transcriptsEnabled, transcriptStatus, transcriptsSummary, } from "./transcripts.js";
|
|
26
|
-
import { transcriptFileName, transcriptJson } from "./transcript-export.js";
|
|
27
|
+
import { editTranscript, forgetTranscriptFailures, forgetTranscripts, makeTranscript, onTranscriptsChange, readyTranscript, setTranscriptsEnabled, statusText, transcriptsEnabled, transcriptStatus, transcriptsSummary, transcriptVersion, } from "./transcripts.js";
|
|
28
|
+
import { transcriptFileName, transcriptJson, transcriptsFileText, } from "./transcript-export.js";
|
|
29
|
+
import { openTranscriptEditor } from "./transcript-editor.js";
|
|
30
|
+
import { subtitleWords, webVtt } from "./subtitles.js";
|
|
27
31
|
import { wordFlag } from "./transcript-align.js";
|
|
28
32
|
import { canvasRecorder } from "../lib/main-control.js";
|
|
29
33
|
import { watchServiceWorkerReady } from "./delay-files.js";
|
|
@@ -416,7 +420,7 @@ window.showFrame = showFrame;
|
|
|
416
420
|
// Two separate things, though they usually agree:
|
|
417
421
|
//
|
|
418
422
|
// * The **root**: the component the Visual Editor works on, picked in the
|
|
419
|
-
// chapter <select>.
|
|
423
|
+
// chapter <select>. TimedKeyframe times, the timeline at the bottom, and every
|
|
420
424
|
// "now" the editors show are measured from the root's start. See
|
|
421
425
|
// rootStartMs and playheadInRootMs().
|
|
422
426
|
// * The **play limits**: where playback wraps or stops, and the ends of the
|
|
@@ -443,7 +447,7 @@ let sectionStartTime = 0;
|
|
|
443
447
|
*/
|
|
444
448
|
let sectionEndTime = 0;
|
|
445
449
|
/**
|
|
446
|
-
* When the Visual Editor's root starts, in video time.
|
|
450
|
+
* When the Visual Editor's root starts, in video time. TimedKeyframe times, the
|
|
447
451
|
* timeline, and every "now" the editors show are measured from here.
|
|
448
452
|
*/
|
|
449
453
|
let rootStartMs = 0;
|
|
@@ -919,6 +923,24 @@ addEventListener("keydown", (event) => {
|
|
|
919
923
|
event.preventDefault();
|
|
920
924
|
}
|
|
921
925
|
});
|
|
926
|
+
// The math's self-test, once per page load. It used to run as transforms.ts loaded, which
|
|
927
|
+
// kept PathShape and everything that uses it out of Node.
|
|
928
|
+
checkPanAndZoom();
|
|
929
|
+
// MARK: Wheel over a number
|
|
930
|
+
/**
|
|
931
|
+
* Chrome changes a focused number field when the wheel, or a two finger scroll, passes over
|
|
932
|
+
* it. Here that's nearly always an accident: scrolling the properties to find the next
|
|
933
|
+
* one. And Cmd+Z can't undo it. So the field gives up the focus first, and the wheel
|
|
934
|
+
* scrolls as usual. Typing and the field's arrows still work.
|
|
935
|
+
*/
|
|
936
|
+
document.addEventListener("wheel", (event) => {
|
|
937
|
+
const target = event.target;
|
|
938
|
+
if (target instanceof HTMLInputElement &&
|
|
939
|
+
target.type === "number" &&
|
|
940
|
+
target === document.activeElement) {
|
|
941
|
+
target.blur();
|
|
942
|
+
}
|
|
943
|
+
}, { passive: true, capture: true });
|
|
922
944
|
/**
|
|
923
945
|
* This is the status of the save. It has no purpose during live / realtime operation
|
|
924
946
|
* so it initialize it to blank.
|
|
@@ -1100,8 +1122,9 @@ function escapeHtml(text) {
|
|
|
1100
1122
|
* Save dialog can change it, just for this file. Nothing else sees the change: the picture
|
|
1101
1123
|
* is still drawn in canvasRecorder's units, and simply stretched to this size.
|
|
1102
1124
|
* @param pixelHeight The saved file's height. See `pixelWidth`.
|
|
1125
|
+
* @param subtitles Add a subtitle track, made from the transcripts. See dev/subtitles.ts.
|
|
1103
1126
|
*/
|
|
1104
|
-
async function startRecording(saveStartMs = 0, saveEndMs = toShow.duration, pixelWidth = canvasRecorder.pixelWidth, pixelHeight = canvasRecorder.pixelHeight) {
|
|
1127
|
+
async function startRecording(saveStartMs = 0, saveEndMs = toShow.duration, pixelWidth = canvasRecorder.pixelWidth, pixelHeight = canvasRecorder.pixelHeight, subtitles = false) {
|
|
1105
1128
|
stopAudio();
|
|
1106
1129
|
startRecordingButton.disabled = true;
|
|
1107
1130
|
liveControls.disabled = true;
|
|
@@ -1175,6 +1198,19 @@ async function startRecording(saveStartMs = 0, saveEndMs = toShow.duration, pixe
|
|
|
1175
1198
|
bitrate: QUALITY_HIGH,
|
|
1176
1199
|
});
|
|
1177
1200
|
output.addAudioTrack(audioSource);
|
|
1201
|
+
// The words, from the transcripts as they are now. The cues are added at the end, like
|
|
1202
|
+
// the sound, when it's known how much was recorded. A track with no cues isn't written.
|
|
1203
|
+
const spokenWords = subtitles
|
|
1204
|
+
? subtitleWords(collectSoundClips(toShow), (source) => readyTranscript(source)?.words)
|
|
1205
|
+
: [];
|
|
1206
|
+
let subtitleSource;
|
|
1207
|
+
if (spokenWords.length) {
|
|
1208
|
+
subtitleSource = new TextSubtitleSource("webvtt");
|
|
1209
|
+
output.addSubtitleTrack(subtitleSource, {
|
|
1210
|
+
languageCode: "eng",
|
|
1211
|
+
name: "Subtitles",
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1178
1214
|
const startTime = performance.now();
|
|
1179
1215
|
await output.start();
|
|
1180
1216
|
infoDiv.innerHTML = "Recording in progress...";
|
|
@@ -1239,6 +1275,11 @@ async function startRecording(saveStartMs = 0, saveEndMs = toShow.duration, pixe
|
|
|
1239
1275
|
}
|
|
1240
1276
|
await audioSource.add(trimmedAudio);
|
|
1241
1277
|
}
|
|
1278
|
+
if (subtitleSource) {
|
|
1279
|
+
const text = webVtt(spokenWords, audioStartMs, audioStartMs + actualAudioMs);
|
|
1280
|
+
if (text)
|
|
1281
|
+
await subtitleSource.add(text);
|
|
1282
|
+
}
|
|
1242
1283
|
infoDiv.innerHTML = "Frames complete. Finalizing video.";
|
|
1243
1284
|
cancelRecordingButton.disabled = true;
|
|
1244
1285
|
await output.finalize(); // Finishes encoding + closes stream automatically
|
|
@@ -1410,6 +1451,22 @@ function updateSaveDialogInfo() {
|
|
|
1410
1451
|
saveInfoFrames.textContent = framesBetween(startMs, endMs).toLocaleString();
|
|
1411
1452
|
saveInfoFrames.style.color = invalid ? "red" : "";
|
|
1412
1453
|
updateSaveSizeNote();
|
|
1454
|
+
updateSaveSubtitlesNote(startMs, endMs);
|
|
1455
|
+
}
|
|
1456
|
+
const saveSubtitlesCheckbox = getById("saveSubtitles", HTMLInputElement);
|
|
1457
|
+
const saveSubtitlesNote = getById("saveSubtitlesNote", HTMLSpanElement);
|
|
1458
|
+
/** How many words the subtitles will have, and which sound files have no transcript yet. */
|
|
1459
|
+
function updateSaveSubtitlesNote(startMs, endMs) {
|
|
1460
|
+
const placed = collectSoundClips(toShow);
|
|
1461
|
+
const missing = new Set(placed
|
|
1462
|
+
.map((clip) => clip.source)
|
|
1463
|
+
.filter((source) => !readyTranscript(source))).size;
|
|
1464
|
+
const count = subtitleWords(placed, (source) => readyTranscript(source)?.words).filter((word) => word.startMs >= startMs && word.startMs < endMs).length;
|
|
1465
|
+
const words = `${count.toLocaleString()} ${count === 1 ? "word" : "words"}`;
|
|
1466
|
+
saveSubtitlesNote.textContent = missing
|
|
1467
|
+
? `${words}. ${missing} sound ${missing === 1 ? "file has" : "files have"} no transcript yet, so ${missing === 1 ? "it isn't" : "they aren't"} included.`
|
|
1468
|
+
: words;
|
|
1469
|
+
saveSubtitlesNote.style.color = missing ? "#a06000" : "#555";
|
|
1413
1470
|
}
|
|
1414
1471
|
function setSaveRange(startMs, endMs) {
|
|
1415
1472
|
saveStartSecondsInput.value = (startMs / 1000).toString();
|
|
@@ -1491,7 +1548,7 @@ saveOkBtn.addEventListener("click", async () => {
|
|
|
1491
1548
|
if (!(await saveDialogLocalFilesReady()))
|
|
1492
1549
|
return;
|
|
1493
1550
|
saveDialog.close();
|
|
1494
|
-
startRecording(startMs, endMs, width, height);
|
|
1551
|
+
startRecording(startMs, endMs, width, height, saveSubtitlesCheckbox.checked);
|
|
1495
1552
|
});
|
|
1496
1553
|
startRecordingButton.addEventListener("click", () => {
|
|
1497
1554
|
populateSaveChapterSelect();
|
|
@@ -1696,13 +1753,24 @@ philDebug.VisualEditor = {
|
|
|
1696
1753
|
get rootComponent() {
|
|
1697
1754
|
return currentRoot();
|
|
1698
1755
|
},
|
|
1756
|
+
/** What the component list shows as selected: the root, when no child is. */
|
|
1699
1757
|
get selectedComponent() {
|
|
1700
|
-
return selectedSlideChild;
|
|
1758
|
+
return selectedSlideChild ?? currentRoot() ?? null;
|
|
1701
1759
|
},
|
|
1702
1760
|
/** Current time in ms relative to the start of the Visual Editor's root. */
|
|
1703
1761
|
get localTimeMs() {
|
|
1704
1762
|
return playheadInRootMs();
|
|
1705
1763
|
},
|
|
1764
|
+
/**
|
|
1765
|
+
* After changing components from the console: show the changes. The same as
|
|
1766
|
+
* {@link VisualEditorAPI.refreshGUI}.
|
|
1767
|
+
* @param howMuch "properties" (the default) after changing values, and "structure" after
|
|
1768
|
+
* adding or removing components. Both save. "sound" rebuilds the sound from its clips, and
|
|
1769
|
+
* doesn't save.
|
|
1770
|
+
*/
|
|
1771
|
+
refreshGUI(howMuch = "properties") {
|
|
1772
|
+
visualEditorAPI.refreshGUI(howMuch);
|
|
1773
|
+
},
|
|
1706
1774
|
};
|
|
1707
1775
|
const scheduleHistoryControls = getById("scheduleHistoryControls", HTMLElement);
|
|
1708
1776
|
const openHistoryDialogBtn = getById("openHistoryDialogBtn", HTMLButtonElement);
|
|
@@ -2158,6 +2226,7 @@ transcriptsCheckbox.addEventListener("change", () => {
|
|
|
2158
2226
|
onTranscriptsChange(() => {
|
|
2159
2227
|
transcriptsStatusSpan.textContent = transcriptsSummary();
|
|
2160
2228
|
timelineDisplay.redraw();
|
|
2229
|
+
requestTranscriptsSync();
|
|
2161
2230
|
});
|
|
2162
2231
|
// The transcript as text. It rebuilds itself when the clips or transcripts
|
|
2163
2232
|
// change, so it needs no calls besides the one in showFrame().
|
|
@@ -2387,7 +2456,7 @@ function clipText(clip, maxWords = Infinity) {
|
|
|
2387
2456
|
*/
|
|
2388
2457
|
function timelineWords(clip, transcript, clipStart) {
|
|
2389
2458
|
const fromMs = clip.startMsIntoClip ?? 0;
|
|
2390
|
-
const key = `${clipStart}|${fromMs}|${soundClipLengthMs(clip)}|${transcript
|
|
2459
|
+
const key = `${clipStart}|${fromMs}|${soundClipLengthMs(clip)}|${transcriptVersion(transcript)}`;
|
|
2391
2460
|
const memo = timelineWordsMemo.get(clip);
|
|
2392
2461
|
if (memo?.key === key)
|
|
2393
2462
|
return memo;
|
|
@@ -2689,12 +2758,12 @@ function restorePlace(place) {
|
|
|
2689
2758
|
* restart the user with the same gui settings.
|
|
2690
2759
|
*/
|
|
2691
2760
|
function saveState() {
|
|
2692
|
-
sessionStorage.setItem("place", JSON.stringify(placeToRestore ?? currentPlace()));
|
|
2693
|
-
sessionStorage.setItem("playPositionLocal", playPositionLocal.checked ? "1" : "0");
|
|
2694
|
-
sessionStorage.setItem("zoomSelect", zoomSelect.value);
|
|
2695
|
-
sessionStorage.setItem("panX", panX.toString());
|
|
2696
|
-
sessionStorage.setItem("panY", panY.toString());
|
|
2697
|
-
sessionStorage.setItem("quality", querySelector('input[name="quality"]:checked', HTMLInputElement).value);
|
|
2761
|
+
sessionStorage.setItem(sessionKey("place"), JSON.stringify(placeToRestore ?? currentPlace()));
|
|
2762
|
+
sessionStorage.setItem(sessionKey("playPositionLocal"), playPositionLocal.checked ? "1" : "0");
|
|
2763
|
+
sessionStorage.setItem(sessionKey("zoomSelect"), zoomSelect.value);
|
|
2764
|
+
sessionStorage.setItem(sessionKey("panX"), panX.toString());
|
|
2765
|
+
sessionStorage.setItem(sessionKey("panY"), panY.toString());
|
|
2766
|
+
sessionStorage.setItem(sessionKey("quality"), querySelector('input[name="quality"]:checked', HTMLInputElement).value);
|
|
2698
2767
|
// Splitter positions — only persist if an explicit size was set by drag or restore.
|
|
2699
2768
|
const topLeft = getById("top-left", HTMLDivElement);
|
|
2700
2769
|
const topRight = getById("top-right", HTMLDivElement);
|
|
@@ -2711,6 +2780,24 @@ addEventListener("pagehide", (_event) => {
|
|
|
2711
2780
|
});
|
|
2712
2781
|
// MARK: Schedule persistence (IndexedDB)
|
|
2713
2782
|
const toShowKey = startRequest.name;
|
|
2783
|
+
/**
|
|
2784
|
+
* This video's own sessionStorage key for `name`. Two videos opened in one tab don't share
|
|
2785
|
+
* a place, a zoom or an unload backup. The pane sizes are the window's layout, so they stay
|
|
2786
|
+
* shared, under plain names.
|
|
2787
|
+
*/
|
|
2788
|
+
function sessionKey(name) {
|
|
2789
|
+
return `${name}|${toShowKey}`;
|
|
2790
|
+
}
|
|
2791
|
+
/** Everything {@link sessionKey} names. Before 0.8.4 they were plain names, shared by every video. */
|
|
2792
|
+
const PER_VIDEO_SESSION_KEYS = [
|
|
2793
|
+
"place",
|
|
2794
|
+
"playPositionLocal",
|
|
2795
|
+
"zoomSelect",
|
|
2796
|
+
"panX",
|
|
2797
|
+
"panY",
|
|
2798
|
+
"quality",
|
|
2799
|
+
"pendingScheduleSave",
|
|
2800
|
+
];
|
|
2714
2801
|
function isMarker(e) {
|
|
2715
2802
|
return "kind" in e;
|
|
2716
2803
|
}
|
|
@@ -2956,6 +3043,110 @@ const diffSync = new SyncedFile({
|
|
|
2956
3043
|
// The old Save Diffs button asked every time; its record is only a suggestion.
|
|
2957
3044
|
...keyedSyncStorage(`__diff-save__|${toShowKey}`, false),
|
|
2958
3045
|
});
|
|
3046
|
+
/**
|
|
3047
|
+
* Every transcript the video uses, mirrored to a JSON file, so they can be read and checked
|
|
3048
|
+
* outside the editor: by you, by grep, or by Claude. It's only a copy. The transcripts
|
|
3049
|
+
* themselves, with the Transcript Editor's changes, live in IndexedDB.
|
|
3050
|
+
*/
|
|
3051
|
+
const transcriptsSync = new SyncedFile({
|
|
3052
|
+
checkbox: getById("transcriptsSyncCheckbox", HTMLInputElement),
|
|
3053
|
+
status: getById("transcriptsSyncStatus", HTMLSpanElement),
|
|
3054
|
+
picker: {
|
|
3055
|
+
id: "transcripts-save",
|
|
3056
|
+
types: JSON_FILE_TYPES,
|
|
3057
|
+
defaultName: () => `${toShowKey || "video"}-transcripts.json`,
|
|
3058
|
+
},
|
|
3059
|
+
render: () => transcriptsFileText(toShowKey, videoTranscripts()),
|
|
3060
|
+
...keyedSyncStorage(`__transcripts-save__|${toShowKey}`, false),
|
|
3061
|
+
});
|
|
3062
|
+
/**
|
|
3063
|
+
* Each sound file the whole video uses, once, in order of first use. Asking about a file
|
|
3064
|
+
* starts its transcript, so this only runs while the transcripts file is being synced.
|
|
3065
|
+
*/
|
|
3066
|
+
function videoTranscripts() {
|
|
3067
|
+
const usesBySource = new Map();
|
|
3068
|
+
const placed = collectSoundClips(toShow).sort((a, b) => a.startMs - b.startMs);
|
|
3069
|
+
for (const clip of placed) {
|
|
3070
|
+
let uses = usesBySource.get(clip.source);
|
|
3071
|
+
if (!uses)
|
|
3072
|
+
usesBySource.set(clip.source, (uses = []));
|
|
3073
|
+
uses.push({
|
|
3074
|
+
startsInVideoMs: clip.startMs,
|
|
3075
|
+
playsFileFromMs: clip.trimMs,
|
|
3076
|
+
playsFileToMs: Number.isFinite(clip.lengthMs)
|
|
3077
|
+
? clip.trimMs + clip.lengthMs
|
|
3078
|
+
: null,
|
|
3079
|
+
});
|
|
3080
|
+
}
|
|
3081
|
+
return [...usesBySource].map(([source, uses]) => {
|
|
3082
|
+
const status = transcriptStatus(source);
|
|
3083
|
+
return {
|
|
3084
|
+
source,
|
|
3085
|
+
transcript: status?.kind === "ready" ? status.transcript : undefined,
|
|
3086
|
+
status: !status
|
|
3087
|
+
? "transcripts are off"
|
|
3088
|
+
: (statusText(status) ?? status.kind),
|
|
3089
|
+
uses,
|
|
3090
|
+
};
|
|
3091
|
+
});
|
|
3092
|
+
}
|
|
3093
|
+
/** What the transcripts file was last asked to show. See {@link requestTranscriptsSync}. */
|
|
3094
|
+
let transcriptsSyncSignature = "";
|
|
3095
|
+
/**
|
|
3096
|
+
* Bring the transcripts file up to date, if anything in it could have changed: a transcript,
|
|
3097
|
+
* or which part of which file the video plays. Cheap when nothing did, so call it often.
|
|
3098
|
+
*/
|
|
3099
|
+
function requestTranscriptsSync() {
|
|
3100
|
+
if (!transcriptsSync.handle)
|
|
3101
|
+
return;
|
|
3102
|
+
const placed = collectSoundClips(toShow);
|
|
3103
|
+
const signature = JSON.stringify(placed.map((clip) => {
|
|
3104
|
+
const transcript = readyTranscript(clip.source);
|
|
3105
|
+
return [
|
|
3106
|
+
clip.source,
|
|
3107
|
+
clip.startMs,
|
|
3108
|
+
clip.trimMs,
|
|
3109
|
+
clip.lengthMs,
|
|
3110
|
+
transcript ? transcriptVersion(transcript) : 0,
|
|
3111
|
+
];
|
|
3112
|
+
}));
|
|
3113
|
+
if (signature === transcriptsSyncSignature)
|
|
3114
|
+
return;
|
|
3115
|
+
transcriptsSyncSignature = signature;
|
|
3116
|
+
transcriptsSync.request();
|
|
3117
|
+
}
|
|
3118
|
+
// MARK: 💾 Files
|
|
3119
|
+
const filesBtn = getById("filesBtn", HTMLButtonElement);
|
|
3120
|
+
const filesDialog = getById("filesDialog", HTMLDialogElement);
|
|
3121
|
+
filesBtn.addEventListener("click", () => filesDialog.showModal());
|
|
3122
|
+
getById("filesDialogCloseBtn", HTMLButtonElement).addEventListener("click", () => filesDialog.close());
|
|
3123
|
+
/**
|
|
3124
|
+
* The button stands for every synced file: red when one needs a click, orange while one is
|
|
3125
|
+
* waiting for the next save. Its tooltip lists them.
|
|
3126
|
+
*/
|
|
3127
|
+
function drawFilesButton() {
|
|
3128
|
+
const syncs = [
|
|
3129
|
+
["Sync to file", jsonSync],
|
|
3130
|
+
["Sync defaults", defaultsSync],
|
|
3131
|
+
["Sync diffs", diffSync],
|
|
3132
|
+
["Sync transcripts", transcriptsSync],
|
|
3133
|
+
];
|
|
3134
|
+
const summaries = syncs.map(([, sync]) => sync.summary);
|
|
3135
|
+
const action = summaries.includes("action");
|
|
3136
|
+
const pending = summaries.includes("pending");
|
|
3137
|
+
filesBtn.textContent = `💾 Files${action ? " ⚠" : pending ? " *" : ""}`;
|
|
3138
|
+
filesBtn.style.background = action ? "#e53935" : pending ? "#ffb74d" : "";
|
|
3139
|
+
filesBtn.style.color = action ? "white" : "";
|
|
3140
|
+
filesBtn.title = [
|
|
3141
|
+
action
|
|
3142
|
+
? "Something needs a click. Open this to see what."
|
|
3143
|
+
: "Import, Save Copy As, and the files on disk that follow your work.",
|
|
3144
|
+
"",
|
|
3145
|
+
...syncs.map(([name, sync]) => `${name}: ${sync.statusText}`),
|
|
3146
|
+
].join("\n");
|
|
3147
|
+
}
|
|
3148
|
+
onSyncStatusChange(drawFilesButton);
|
|
3149
|
+
drawFilesButton();
|
|
2959
3150
|
/** The code-defined starting point, in the same format as {@link buildJsonSnapshot}. */
|
|
2960
3151
|
function buildDefaultsSnapshot() {
|
|
2961
3152
|
return {
|
|
@@ -3488,7 +3679,7 @@ async function initFromDB(unloadBackup) {
|
|
|
3488
3679
|
_loadSource = source;
|
|
3489
3680
|
_baselineTreeJson = currentTreeJson();
|
|
3490
3681
|
// The unload backup is in the database now, or older than it. See the end of "Load previous state".
|
|
3491
|
-
sessionStorage.removeItem("pendingScheduleSave");
|
|
3682
|
+
sessionStorage.removeItem(sessionKey("pendingScheduleSave"));
|
|
3492
3683
|
canvas.style.visibility = "";
|
|
3493
3684
|
canvasLoading.style.display = "none";
|
|
3494
3685
|
const currentSel = currentRoot();
|
|
@@ -3529,6 +3720,7 @@ async function saveVideoState(force = false) {
|
|
|
3529
3720
|
finally {
|
|
3530
3721
|
jsonSync.request();
|
|
3531
3722
|
diffSync.request();
|
|
3723
|
+
requestTranscriptsSync();
|
|
3532
3724
|
}
|
|
3533
3725
|
}
|
|
3534
3726
|
async function saveVideoStateToDb(force) {
|
|
@@ -3629,7 +3821,7 @@ function saveOnUnload() {
|
|
|
3629
3821
|
if (dirty && !previewing)
|
|
3630
3822
|
void saveVideoState();
|
|
3631
3823
|
try {
|
|
3632
|
-
sessionStorage.setItem("pendingScheduleSave", JSON.stringify([backup]));
|
|
3824
|
+
sessionStorage.setItem(sessionKey("pendingScheduleSave"), JSON.stringify([backup]));
|
|
3633
3825
|
}
|
|
3634
3826
|
catch (e) {
|
|
3635
3827
|
// One whole tree can exceed the ~5MB sessionStorage quota on a big video. The
|
|
@@ -4107,7 +4299,7 @@ function buildScheduleSection(info, selectable) {
|
|
|
4107
4299
|
rebuild();
|
|
4108
4300
|
}
|
|
4109
4301
|
const legend = document.createElement("legend");
|
|
4110
|
-
legend.textContent = info
|
|
4302
|
+
legend.textContent = propertyLabel(info) + " ";
|
|
4111
4303
|
const addBtn = document.createElement("button");
|
|
4112
4304
|
addBtn.type = "button";
|
|
4113
4305
|
addBtn.textContent = "+ Add";
|
|
@@ -4228,6 +4420,15 @@ function buildScheduleSection(info, selectable) {
|
|
|
4228
4420
|
const durationLabel = info.timeAxisLabel
|
|
4229
4421
|
? `Δ ${info.timeAxisLabel}`
|
|
4230
4422
|
: "Duration (ms)";
|
|
4423
|
+
/**
|
|
4424
|
+
* A text box takes any spare width. The table fills the panel, and its Value column asks
|
|
4425
|
+
* for all of it. That alone would squeeze the other columns to their narrowest, wrapping
|
|
4426
|
+
* "Go To", so `.grow-value` in canvas-recorder.css keeps the headers on one line until the
|
|
4427
|
+
* panel is really too narrow.
|
|
4428
|
+
*/
|
|
4429
|
+
const growValue = info.type === "string" && !info.useDialog && !info.choices?.length;
|
|
4430
|
+
if (growValue)
|
|
4431
|
+
table.style.width = "100%";
|
|
4231
4432
|
for (const h of [
|
|
4232
4433
|
showDurations ? durationLabel : timeLabel,
|
|
4233
4434
|
...valueHeaders,
|
|
@@ -4237,6 +4438,8 @@ function buildScheduleSection(info, selectable) {
|
|
|
4237
4438
|
]) {
|
|
4238
4439
|
const th = document.createElement("th");
|
|
4239
4440
|
th.textContent = h;
|
|
4441
|
+
if (growValue && h === "Value")
|
|
4442
|
+
th.style.width = "100%";
|
|
4240
4443
|
headerRow.append(th);
|
|
4241
4444
|
}
|
|
4242
4445
|
// Maps each keyframe object to its ease cell, so visibility updates
|
|
@@ -4484,6 +4687,8 @@ function buildScheduleSection(info, selectable) {
|
|
|
4484
4687
|
input.value = strKf.value;
|
|
4485
4688
|
input.style.cssText =
|
|
4486
4689
|
"width:100%;box-sizing:border-box;resize:vertical";
|
|
4690
|
+
// See growValue.
|
|
4691
|
+
cell.style.width = "100%";
|
|
4487
4692
|
input.addEventListener("input", () => {
|
|
4488
4693
|
strKf.value = input.value;
|
|
4489
4694
|
});
|
|
@@ -4496,7 +4701,8 @@ function buildScheduleSection(info, selectable) {
|
|
|
4496
4701
|
const sel = addName(document.createElement("select"));
|
|
4497
4702
|
for (const choice of info.choices) {
|
|
4498
4703
|
const opt = document.createElement("option");
|
|
4499
|
-
opt.value =
|
|
4704
|
+
opt.value = choice;
|
|
4705
|
+
opt.textContent = choiceLabel(info, choice);
|
|
4500
4706
|
sel.append(opt);
|
|
4501
4707
|
}
|
|
4502
4708
|
sel.value = strKf.value;
|
|
@@ -4852,7 +5058,15 @@ function buildScheduleSection(info, selectable) {
|
|
|
4852
5058
|
// Also fills in the "at …" labels in Durations mode.
|
|
4853
5059
|
refreshRippled();
|
|
4854
5060
|
table.append(tbody);
|
|
4855
|
-
|
|
5061
|
+
if (growValue) {
|
|
5062
|
+
const wrapper = document.createElement("div");
|
|
5063
|
+
wrapper.className = "grow-value";
|
|
5064
|
+
wrapper.append(table);
|
|
5065
|
+
section.append(wrapper);
|
|
5066
|
+
}
|
|
5067
|
+
else {
|
|
5068
|
+
section.append(table);
|
|
5069
|
+
}
|
|
4856
5070
|
section.addEventListener("input", () => {
|
|
4857
5071
|
activeRootComponentEditor?.update(selectable, info);
|
|
4858
5072
|
});
|
|
@@ -5041,7 +5255,7 @@ function updateComponentEditor(selectable) {
|
|
|
5041
5255
|
const pasteIntoBtn = document.createElement("button");
|
|
5042
5256
|
pasteIntoBtn.type = "button";
|
|
5043
5257
|
pasteIntoBtn.textContent = "📋 → 🖥️";
|
|
5044
|
-
pasteIntoBtn.title = `Paste into "${child.description}"`;
|
|
5258
|
+
pasteIntoBtn.title = `Paste into "${child.userEditableDescription ?? child.description}"`;
|
|
5045
5259
|
pasteIntoBtn.addEventListener("click", () => pasteInto(child, selectable));
|
|
5046
5260
|
row.append(pasteIntoBtn);
|
|
5047
5261
|
}
|
|
@@ -5080,7 +5294,7 @@ function updateComponentEditor(selectable) {
|
|
|
5080
5294
|
const rootPasteBtn = document.createElement("button");
|
|
5081
5295
|
rootPasteBtn.type = "button";
|
|
5082
5296
|
rootPasteBtn.textContent = "📋 → 🖥️";
|
|
5083
|
-
rootPasteBtn.title = `Paste into "${selectable.description}"`;
|
|
5297
|
+
rootPasteBtn.title = `Paste into "${selectable.userEditableDescription ?? selectable.description}"`;
|
|
5084
5298
|
rootPasteBtn.addEventListener("click", () => pasteInto(selectable, selectable));
|
|
5085
5299
|
rootRow.append(rootEditBtn);
|
|
5086
5300
|
if (selectable.setDuration !== undefined) {
|
|
@@ -5381,6 +5595,44 @@ function buildSoundClipSection(selectable) {
|
|
|
5381
5595
|
});
|
|
5382
5596
|
downloadBlob(transcriptFileName(clip.source), new Blob([json], { type: "application/json" }));
|
|
5383
5597
|
});
|
|
5598
|
+
const editTranscriptBtn = document.createElement("button");
|
|
5599
|
+
editTranscriptBtn.type = "button";
|
|
5600
|
+
editTranscriptBtn.textContent = "✎";
|
|
5601
|
+
editTranscriptBtn.title =
|
|
5602
|
+
"Edit Transcript… Fix this file's words and their times, for the timeline, 📖 Text and the subtitles.";
|
|
5603
|
+
editTranscriptBtn.addEventListener("click", () => {
|
|
5604
|
+
if (!readyTranscript(clip.source)) {
|
|
5605
|
+
alert(transcriptsEnabled()
|
|
5606
|
+
? "This clip's transcript isn't ready yet. Its progress shows on the timeline."
|
|
5607
|
+
: "Transcripts are off. Turn on 🗣 Transcripts above the timeline.");
|
|
5608
|
+
return;
|
|
5609
|
+
}
|
|
5610
|
+
const fromMs = clip.startMsIntoClip ?? 0;
|
|
5611
|
+
const playheadInFile = playheadInOwner() - clip.startMsIntoScene + fromMs;
|
|
5612
|
+
const lengthMs = soundClipLengthMs(clip) ?? Infinity;
|
|
5613
|
+
openTranscriptEditor({
|
|
5614
|
+
source: clip.source,
|
|
5615
|
+
words: () => readyTranscript(clip.source)?.words,
|
|
5616
|
+
setWords: (words) => editTranscript(clip.source, words),
|
|
5617
|
+
audio: () => soundtrack.getDecodedBuffer(clip.source),
|
|
5618
|
+
// Every clip in the video that plays this file, not just this one.
|
|
5619
|
+
used: collectSoundClips(toShow)
|
|
5620
|
+
.filter((placed) => placed.source === clip.source)
|
|
5621
|
+
.map((placed) => ({
|
|
5622
|
+
fromMs: placed.trimMs,
|
|
5623
|
+
toMs: placed.trimMs + placed.lengthMs,
|
|
5624
|
+
})),
|
|
5625
|
+
// The playhead, if it's in this clip, or else the clip's start.
|
|
5626
|
+
startAtMs: playheadInFile >= fromMs && playheadInFile < fromMs + lengthMs
|
|
5627
|
+
? playheadInFile
|
|
5628
|
+
: fromMs,
|
|
5629
|
+
pausePlayer() {
|
|
5630
|
+
playCheckBox.checked = false;
|
|
5631
|
+
stopAudio();
|
|
5632
|
+
},
|
|
5633
|
+
closed: () => timelineDisplay.redraw(),
|
|
5634
|
+
});
|
|
5635
|
+
});
|
|
5384
5636
|
const splitBtn = document.createElement("button");
|
|
5385
5637
|
splitBtn.type = "button";
|
|
5386
5638
|
splitBtn.textContent = "✂";
|
|
@@ -5420,7 +5672,7 @@ function buildSoundClipSection(selectable) {
|
|
|
5420
5672
|
selectedSoundClip = kept[0];
|
|
5421
5673
|
afterStructureChange();
|
|
5422
5674
|
});
|
|
5423
|
-
row1.append(notesInput, fromTranscriptBtn, saveTranscriptBtn, splitBtn, upBtn, downBtn, delBtn);
|
|
5675
|
+
row1.append(notesInput, fromTranscriptBtn, saveTranscriptBtn, editTranscriptBtn, splitBtn, upBtn, downBtn, delBtn);
|
|
5424
5676
|
// Row 2: source URL
|
|
5425
5677
|
const row2 = document.createElement("div");
|
|
5426
5678
|
row2.style.cssText =
|
|
@@ -6799,8 +7051,10 @@ function applyMarkerDrag(localX, localY, shiftKey = false) {
|
|
|
6799
7051
|
}
|
|
6800
7052
|
// MARK: Load previous state.
|
|
6801
7053
|
{
|
|
6802
|
-
//
|
|
6803
|
-
|
|
7054
|
+
// This video's unload backup, if the last session left one. Before 0.8.4 it was under a
|
|
7055
|
+
// plain name, for whichever video was open last. initFromDB() checks that it's this one's.
|
|
7056
|
+
const unloadBackup = sessionStorage.getItem(sessionKey("pendingScheduleSave")) ??
|
|
7057
|
+
sessionStorage.getItem("pendingScheduleSave");
|
|
6804
7058
|
// Hide the canvas until DB restoration is complete to prevent the TypeScript-
|
|
6805
7059
|
// default state from flashing briefly before the saved state is applied.
|
|
6806
7060
|
canvas.style.visibility = "hidden";
|
|
@@ -6832,6 +7086,7 @@ function applyMarkerDrag(localX, localY, shiftKey = false) {
|
|
|
6832
7086
|
jsonSync.request();
|
|
6833
7087
|
diffSync.request();
|
|
6834
7088
|
defaultsSync.request();
|
|
7089
|
+
requestTranscriptsSync();
|
|
6835
7090
|
});
|
|
6836
7091
|
// Sanity-check DB for timestamps in the future (clock skew, corrupted data).
|
|
6837
7092
|
void (async () => {
|
|
@@ -6853,19 +7108,19 @@ function applyMarkerDrag(localX, localY, shiftKey = false) {
|
|
|
6853
7108
|
// So when you configure the web page, and you hit refresh, or the page automatically
|
|
6854
7109
|
// refreshes, you don't lose your settings.
|
|
6855
7110
|
try {
|
|
6856
|
-
if (sessionStorage.getItem("playPositionLocal") === "0") {
|
|
7111
|
+
if (sessionStorage.getItem(sessionKey("playPositionLocal")) === "0") {
|
|
6857
7112
|
const playheadMs = playheadInVideoMs();
|
|
6858
7113
|
playPositionLocal.checked = false;
|
|
6859
7114
|
loadPlayPositionSeconds(playheadMs);
|
|
6860
7115
|
}
|
|
6861
7116
|
// Applied when the saved tree is in: see initFromDB() above.
|
|
6862
|
-
placeToRestore = parseSavedPlace(sessionStorage.getItem("place"));
|
|
6863
|
-
if (sessionStorage.getItem("quality") === "Low Power") {
|
|
7117
|
+
placeToRestore = parseSavedPlace(sessionStorage.getItem(sessionKey("place")));
|
|
7118
|
+
if (sessionStorage.getItem(sessionKey("quality")) === "Low Power") {
|
|
6864
7119
|
getById("lowPower", HTMLInputElement).checked = true;
|
|
6865
7120
|
}
|
|
6866
|
-
const savedZoom = sessionStorage.getItem("zoomSelect");
|
|
6867
|
-
const savedPanX = parseFloatX(sessionStorage.getItem("panX") ?? "");
|
|
6868
|
-
const savedPanY = parseFloatX(sessionStorage.getItem("panY") ?? "");
|
|
7121
|
+
const savedZoom = sessionStorage.getItem(sessionKey("zoomSelect"));
|
|
7122
|
+
const savedPanX = parseFloatX(sessionStorage.getItem(sessionKey("panX")) ?? "");
|
|
7123
|
+
const savedPanY = parseFloatX(sessionStorage.getItem(sessionKey("panY")) ?? "");
|
|
6869
7124
|
if (savedZoom !== null) {
|
|
6870
7125
|
zoomSelect.value = savedZoom;
|
|
6871
7126
|
}
|
|
@@ -6878,7 +7133,7 @@ function applyMarkerDrag(localX, localY, shiftKey = false) {
|
|
|
6878
7133
|
else {
|
|
6879
7134
|
zoomToFit();
|
|
6880
7135
|
}
|
|
6881
|
-
// Restore splitter positions
|
|
7136
|
+
// Restore splitter positions. Shared by every video: they're the window's layout.
|
|
6882
7137
|
// Values are stored as "XX.XX%" (new format) or a bare number in pixels (old).
|
|
6883
7138
|
const topLeftH = sessionStorage.getItem("pane-height-top-left") ?? "";
|
|
6884
7139
|
const topRightH = sessionStorage.getItem("pane-height-top-right") ?? "";
|
|
@@ -6900,12 +7155,22 @@ function applyMarkerDrag(localX, localY, shiftKey = false) {
|
|
|
6900
7155
|
getById("left-col", HTMLDivElement).style.flex = fL;
|
|
6901
7156
|
}
|
|
6902
7157
|
finally {
|
|
6903
|
-
|
|
6904
|
-
//
|
|
6905
|
-
//
|
|
6906
|
-
|
|
7158
|
+
// Each value is read once, at startup. saveState() writes them again as the page goes.
|
|
7159
|
+
// Only this video's: another video in this tab keeps its own until it loads.
|
|
7160
|
+
// The plain names are from before 0.8.4, when every video shared them.
|
|
7161
|
+
for (const name of PER_VIDEO_SESSION_KEYS) {
|
|
7162
|
+
sessionStorage.removeItem(name);
|
|
7163
|
+
// Keep the unload backup until initFromDB() has saved it. If the page reloads before
|
|
7164
|
+
// then, saveOnUnload() saves nothing, so this is the only copy.
|
|
7165
|
+
if (name !== "pendingScheduleSave") {
|
|
7166
|
+
sessionStorage.removeItem(sessionKey(name));
|
|
7167
|
+
}
|
|
7168
|
+
}
|
|
7169
|
+
if (unloadBackup !== null &&
|
|
7170
|
+
sessionStorage.getItem(sessionKey("pendingScheduleSave")) === null) {
|
|
7171
|
+
// It was under the old plain name, removed just above.
|
|
6907
7172
|
try {
|
|
6908
|
-
sessionStorage.setItem("pendingScheduleSave", unloadBackup);
|
|
7173
|
+
sessionStorage.setItem(sessionKey("pendingScheduleSave"), unloadBackup);
|
|
6909
7174
|
}
|
|
6910
7175
|
catch {
|
|
6911
7176
|
// It fit a moment ago.
|
|
@@ -7138,7 +7403,8 @@ getById("dumpDbBtn", HTMLButtonElement).addEventListener("click", async () => {
|
|
|
7138
7403
|
const videoRecord = await readVideoHistory();
|
|
7139
7404
|
const pre = getById("dbDump", HTMLPreElement);
|
|
7140
7405
|
const lines = [];
|
|
7141
|
-
|
|
7406
|
+
const entryCount = videoRecord?.entries.length ?? 0;
|
|
7407
|
+
lines.push(`=== videos["${toShowKey}"] — ${entryCount} ${entryCount === 1 ? "entry" : "entries"} ===`);
|
|
7142
7408
|
const latest = videoRecord?.entries.at(-1);
|
|
7143
7409
|
lines.push(latest ? JSON.stringify(latest, null, 2) : "(none)");
|
|
7144
7410
|
pre.textContent = lines.join("\n");
|
|
@@ -7232,7 +7498,7 @@ async function fetchJsonSnapshot() {
|
|
|
7232
7498
|
*
|
|
7233
7499
|
* A stored entry now covers the entire video, but the Load dialog has always acted on
|
|
7234
7500
|
* whatever the chapter selector points at. Locating `target` inside the snapshot keeps that
|
|
7235
|
-
*
|
|
7501
|
+
* behavior: picking an older entry while a single slide is selected reverts that slide and
|
|
7236
7502
|
* leaves its siblings alone. Selecting the root applies everything.
|
|
7237
7503
|
*/
|
|
7238
7504
|
function applyScopedToTarget(target, tree) {
|
|
@@ -7367,18 +7633,18 @@ function initResizeHandle(handle, topPane) {
|
|
|
7367
7633
|
document.addEventListener("mouseup", onUp);
|
|
7368
7634
|
});
|
|
7369
7635
|
}
|
|
7370
|
-
initResizeHandle(getById("
|
|
7371
|
-
initResizeHandle(getById("
|
|
7636
|
+
initResizeHandle(getById("h-resize-left", HTMLDivElement), getById("top-left", HTMLDivElement));
|
|
7637
|
+
initResizeHandle(getById("h-resize-right", HTMLDivElement), getById("top-right", HTMLDivElement));
|
|
7372
7638
|
{
|
|
7373
|
-
const
|
|
7639
|
+
const vHandle = getById("v-resize", HTMLDivElement);
|
|
7374
7640
|
const leftCol = getById("left-col", HTMLDivElement);
|
|
7375
7641
|
const MIN_COL = 80;
|
|
7376
7642
|
const vStorageKey = "pane-width-left-col";
|
|
7377
|
-
|
|
7643
|
+
vHandle.addEventListener("mousedown", (startEvent) => {
|
|
7378
7644
|
startEvent.preventDefault();
|
|
7379
|
-
|
|
7645
|
+
vHandle.classList.add("dragging");
|
|
7380
7646
|
const totalW = document.body.getBoundingClientRect().width;
|
|
7381
|
-
const handleW =
|
|
7647
|
+
const handleW = vHandle.getBoundingClientRect().width;
|
|
7382
7648
|
const startClientX = startEvent.clientX;
|
|
7383
7649
|
const startColW = leftCol.getBoundingClientRect().width;
|
|
7384
7650
|
const onMove = (e) => {
|
|
@@ -7388,7 +7654,7 @@ initResizeHandle(getById("hresize-right", HTMLDivElement), getById("top-right",
|
|
|
7388
7654
|
zoomToFit();
|
|
7389
7655
|
};
|
|
7390
7656
|
const onUp = () => {
|
|
7391
|
-
|
|
7657
|
+
vHandle.classList.remove("dragging");
|
|
7392
7658
|
document.removeEventListener("mousemove", onMove);
|
|
7393
7659
|
document.removeEventListener("mouseup", onUp);
|
|
7394
7660
|
// flex is "0 0 X%" — store just the percentage part
|