IFrame Embed
The IFrame Embed integration allows video platforms and web applications to embed the full Closed Caption Creator editor directly within their own interface using a standard HTML <iframe> tag. Instead of building a caption editing tool from scratch, development teams can embed a professional-grade editor with support for over 30 subtitle formats, frame-accurate playback, real-time QC, and multilingual workflows — all accessible without ever leaving the host platform.
Communication between the parent application and the embedded editor is handled by PenPal JS, a lightweight cross-window messaging library. Through this connection, the parent page can programmatically load media, import subtitle files, configure project settings, run quality control checks, and retrieve edited content — making it possible to build tightly integrated captioning workflows tailored to any platform's requirements.
Give it our LLM-ready reference with the complete API. See Build with AI.
Getting Started
Before embedding the editor, ensure your application includes PenPal JS. The library is available via CDN and should be loaded in the parent page:
<script src="https://unpkg.com/penpal@^7/dist/penpal.min.js"></script>
Next, add an <iframe> element to your page pointing to the Closed Caption Creator IFrame demo URL. The allow attribute must include clipboard-write, clipboard-read, and encrypted-media for the editor to function correctly:
<div class="iframe-container">
<iframe
id="editor"
src="https://iframe-demo.closedcaptioncreator.com/"
style="width: 100%; height: 90vh;"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; clipboard-read; encrypted-media"
allowfullscreen>
</iframe>
</div>
Once the iframe is in place, use PenPal to establish a connection when the frame loads. The connection.promise resolves to a remote object containing all of the methods exposed by the editor. All calls to these methods are asynchronous and should be awaited:
iframe.addEventListener('load', async () => {
const messenger = new Penpal.WindowMessenger({
remoteWindow: iframe.contentWindow,
allowedOrigins: ['https://iframe-demo.closedcaptioncreator.com']
});
const connection = Penpal.connect({ messenger, methods: {} });
const remote = await connection.promise;
// Optional: apply chrome theme before loading content
// await remote.setAppTheme('dark'); // 'light' | 'dark' | 'auto', match the host app
// await remote.setTheme({ primary: '#408fe0', bodyBg: '#181c24' });
// await remote.loadCustomStyles('[data-bs-theme="dark"] { --bs-primary: #408fe0; }');
// Configure and load the project
await remote.setProjectName("My Project");
await remote.setProjectFrameRate(29.97);
await remote.setProjectDropFrame(true);
await remote.importMedia(mediaUrl);
await remote.importSubtitle(subtitleUrl, "subRip");
});
Key Functions
The following table describes the primary categories of methods available on the remote object. For a complete function reference including all parameters and return values, visit the IFrame Remote Documentation on the Closed Caption Creator website, or download the single-file reference from Build with AI, which lists every method.
| Category | Representative Methods | Description |
|---|---|---|
| Project configuration | setProjectName, setProjectFrameRate, setProjectDropFrame, setProjectIncode, setProjectDescription, setAdLicense | Set project-level metadata before or after loading content. Use setAdLicense(true) to enable Audio Description license mode. |
| Media | importMedia, setPoster, setMediaPeaksPath, setMediaPeaksData, toggleTimeline | Load a video or audio file, set a thumbnail, and configure the audio waveform display. |
| Subtitle import/export | importSubtitle, exportSubtitle | Load a subtitle file from a URL or retrieve the edited captions in any supported output format. See Importing and Exporting Subtitles. |
| Event Groups | addEventGroup, removeEventGroup, mergeEventGroups, getEventGroupInfo, getSelectedEventGroupId, selectEventGroupById | Create, remove, merge, list, and select Event Groups. getEventGroupInfo and getSelectedEventGroupId include each group's BCP-47 language (default en-US), letter tracks in use, custom trackNames, and availableTracks. updateEventGroupTracks and getEventGroupTracks set and read track names and restrictions. |
| Speakers | addSpeaker, getSpeakers | Add speakers by name (with optional ID and colour) and list the project's speakers. |
| Markers | getMarkers, setMarkers, createMarkerList, insertMarker | Read or replace marker lists, create a list, and add markers such as shot changes. |
| Transcript sync | setTranscript, checkSync, resyncEventGroup, loadTranscript | Pass a transcript (for example Deepgram JSON), measure caption drift against it, re-time the selected Event Group to it, or import it as a new group. |
| Display and preview | setDisplaySettings, enableSubtitleMode, enableCaptionMode, setPreviewFontSize, setPreviewFontFamily | Set the caption display area (width, height, padding, line spacing) and how the caption preview renders. |
| Quick Tools | setQuickToolsSettings, selectQuickToolsPanel | Choose which Quick Tools tabs are enabled and open a specific tab. These change the user's Quick Tools settings; for session-only restrictions see Permissions and roles. |
| Keyboard shortcuts | getKeyboardShortcuts, setKeyboardShortcuts | Read the current shortcuts and remap them by shortcut name. |
| App theme / branding | setAppTheme, setTheme, loadCustomStyles, clearTheme | Use setAppTheme("light" | "dark" | "auto") to follow the host app's light/dark mode (this also switches the timeline palette). Customize UI chrome colors, fonts, and borders at runtime. Call immediately after connection.promise resolves so the editor is not briefly unthemed. Build-time customer themes may also ship via assets/css/themes/{system}.css. Does not recolor the Konva timeline. |
| Watermark | setWatermark | Draw a visual watermark (date/time, viewer email, IP address, custom line) over the media player, beneath the caption preview. The host resolves each value and passes it as a string, or null to omit that field. See Watermarking. |
| UI control | toggleStatusModal, updateModalStatus, updateModalTitle, alertUser, completeImport, failImport | Control the progress modal and display alerts to the user during loading sequences. |
| Locking & navigation | enableVideoLock, enableCaptionLock, enablePreviewLock, selectEventById, selectEventByIndex, scrollToEventById, scrollToEventByIndex | Control synchronisation between the video player and the caption list, and select or scroll to events. Event selection and scrolling act on the active Event Group, so call selectEventGroupById first when the event belongs to another group. |
| Quality control | loadStyleGuide, qcEventGroup, getStyleGuides | Load a custom style guide and run validation checks against an Event Group. |
| Data retrieval | getProjectData, loadProjectData, getHistory, hasUnsavedChanges, getSelectedEvents | Retrieve or inject full project data and read the event selection. Use getHistory for a lightweight undo stack summary and hasUnsavedChanges to detect edits since the last clean load/save (compares the undo stack position to the saved baseline; undoing back to that baseline clears the dirty state). To save and restore a project, use getProjectData and loadProjectData: they round-trip Event Group and Event IDs, timings, group names, Event Track settings (trackNames, availableTracks) and each event's track. importSubtitle does not carry over Event Group settings. |
| Auto tools | autoFormat, autoCorrectReadingSpeed, fixEventOverlap, insertBlankFrames, setProjectFrameGap | Programmatically apply formatting and timing corrections to caption tracks. autoCorrectReadingSpeed acts on the selected Event Group; the others take an Event Group index. These methods report most failures, such as a locked group, with a toast in the editor rather than a result object (autoFormat also returns { success: false, message } for a locked group). |
| Audio Description (parent methods) | getVoices, renderAudio | When setAdLicense(true) is set, the iframe routes AD voice listing and TTS through the parent. Expose these methods on the parent's Penpal methods object: getVoices() and renderAudio({ text, voice?, speed?, format?, eventId? }). |
| Toolbar actions | setParentToolbarActions, configureSecondaryToolbar, parent exportSubtitle / cancel | Close and Save in the top-right toolbar are off by default (parentCancel / parentExportSubtitle in envStore). Call the child method setParentToolbarActions({ exportSubtitle?: boolean, cancel?: boolean }) after connection.promise to show them. Clicks invoke the matching parent-side Penpal methods (exportSubtitle() / cancel()); the parent decides what each action does. This is separate from the child exportSubtitle API used to encode/retrieve captions from the iframe. Use configureSecondaryToolbar({ left, center, right }) to choose which secondary-toolbar icons appear, in what order, and in which slot. Omit the call (or pass null) to keep the default iframe layout. |
| Permissions & roles | setRole, getPermissions, configurePrimaryToolbar, setMetadataPermissions, lockEventGroup, setTimelineEnabled, setQuickToolsPanelVisible, setAllowedQuickToolsPanels | Restrict the editor to match your users' roles: hide menus, metadata, Quick Tools, or the timeline, and lock Event Groups. See Permissions and roles. |
Secondary toolbar
The secondary toolbar (Undo, Redo, alignment, split/merge, and other caption tools) can be customized after the PenPal connection resolves. The payload is a full layout for customizable icons: only listed IDs appear, in array order, in the given slot. Omitted slot keys are treated as empty.
await remote.configureSecondaryToolbar({
left: ['undo', 'redo', 'shortcuts'],
center: ['addEvent', 'removeEvent', 'split', 'merge'],
right: ['alignLeft', 'alignCenter', 'alignRight', 'copy', 'cut', 'paste']
});
Pass null (or call the method with no argument) to restore the default iframe layout: Undo, Redo, and Keyboard Shortcuts on the left, and the full caption-editing group on the right.
These icons cannot be shown, hidden, or moved via this method: Open, Save, Media Import, Automatic Transcription, Automatic Translation, and Settings. They stay hidden in iframe mode, matching the existing iframe toolbar. Keyboard shortcuts remain available when an icon is hidden.
Call getSecondaryToolbarOptions() to list the icon IDs the method accepts.
Permissions and roles
Many platforms resave subtitle files without the editor's extra metadata, or need to limit what a user can do based on their role in the host application. The methods below restrict the iframe UI. Every setting is session-only: it is never written to the user's saved settings, and it resets when the iframe reloads.
Role presets
The quickest option is a predefined role:
await remote.setRole('guest'); // preview and playback only
await remote.setRole('reviewer'); // preview, playback, and metadata; text and timing locked
await remote.setRole('editor'); // full access (default)
| Role | Event Groups | Metadata | Menus and toolbars | Quick Tools | Timeline |
|---|---|---|---|---|---|
guest | Locked | Hidden | Edit, Format, Timecode, Insert, and AI Tools menus hidden; no secondary-toolbar icons | Hidden | Visible, read-only |
reviewer | Locked (text and timing) | Editable | Edit menu limited to Undo, Redo, and Go to Event; Undo, Redo, and Shortcuts icons | Info, QC & Review, Manual QC, Errors, Speakers, Tags, Markers, Notes | Visible, read-only |
editor | Unlocked | Editable | Default | Default | Default |
Pass overrides as the second argument to adjust a preset. metadata and primaryToolbar merge key by key; every other key replaces the preset value:
await remote.setRole('reviewer', {
metadata: { tags: false }, // reviewers comment and approve, but no tags
quickToolsAllowed: ['notes', 'markers'],
});
getPermissions() returns the effective settings.
Primary toolbar
configurePrimaryToolbar controls the top menu bar. For each menu, false hides it, true shows its default items, and an array shows only the listed item IDs. Menus you leave out keep their defaults. Call getPrimaryToolbarOptions() to list every menu and item ID.
await remote.configurePrimaryToolbar({
menus: {
edit: ['edit-undo', 'edit-redo', 'edit-goto'],
format: false,
insert: ['insertEventBefore', 'insertEventAfter'],
},
buttons: { fullscreen: false },
});
// remote.configurePrimaryToolbar(null) restores the default toolbar
Only tools available in the iframe can be shown: the File, Help, and CLI Tools menus and online-only items stay hidden whatever the configuration says.
Metadata
setMetadataPermissions hides the UI for notes and replies, approvals, forced subtitles, speakers, recipients, and tags. This covers the event buttons, table columns, context-menu items, keyboard shortcuts, timeline badges, and the matching Quick Tools tabs.
await remote.setMetadataPermissions({ notes: false, tags: false });
Locking Event Groups
A locked Event Group's text and timing cannot be changed, by any editing path including undo and redo. Metadata stays editable unless you hide it with setMetadataPermissions. Locks set by the parent cannot be removed by the user from Event Group Options.
await remote.lockEventGroup(groupId);
await remote.unlockEventGroup(groupId);
await remote.isEventGroupLocked(groupId); // { locked, lockedByParent, lockedByUser, lockedByRole }
await remote.addEventGroup({ name: 'Reference', locked: true });
await remote.setEditingLocked(true); // lock every Event Group
Quick Tools and timeline
await remote.setQuickToolsPanelVisible(false); // hide the whole panel
await remote.setAllowedQuickToolsPanels(['summary', 'notes']); // limit the tabs
await remote.setTimelineEnabled(false); // hide the timeline and its toggle
setAllowedQuickToolsPanels works on top of setQuickToolsSettings: a tab appears only if both allow it.
Watermarking
A visual watermark can be drawn over the media player to deter screen capture of pre-release material. It is an overlay only — it is never burned into the media file or into any subtitle, audio, or video export. Team admins configure the overlay in the editor; see Video Watermarking for the Options workflow.
There are two ways to configure it:
- Teams: a team admin enables and configures it in Edit → Options → Watermark. The settings are stored on the team and applied for every member of that team, who cannot turn it off. Available fields are the current date and time, the signed-in user's email, their IP address, and a custom line of text, plus vertical alignment and text/shadow opacity.
- IFrame hosts: call the
setWatermark(settings)remote method. Host settings take precedence over any team configuration for the rest of the session. Edit → Options is hidden in iframe mode, so hosts must use this API.
The host resolves every display value itself, so the date/time, email, and IP address are supplied as strings (or null when that field should be omitted):
await remote.setWatermark({
enabled: true,
showDateTime: true,
dateTime: "2026-09-14 07:22:43", // "YYYY-MM-DD HH:mm:ss" in the viewer's local time
email: "user@example.com",
ipAddress: "203.0.113.10",
customText: "CONFIDENTIAL",
alignment: "bottom", // "top" | "center" | "bottom"
textOpacity: 100, // 0-100
shadowOpacity: 100 // 0-100
});
The timestamp is static once applied, so call setWatermark again on an interval if the watermark should track the current time. Pass enabled: false to remove the overlay.
Custom Themes
Dedicated offline iframe builds can match a host platform's look by shipping a customer theme stylesheet and logos keyed to the system slug, and/or by calling runtime remote methods from the parent page:
- Build-time:
assets/css/themes/{system}.cssloads automatically for non-demosystems (same slug pattern as{system}.pnglogos). - Runtime:
setAppTheme(mode)switches between light, dark, and auto mode to follow the host app.setTheme(tokens),loadCustomStyles(cssText), andclearTheme()customize chrome colors, fonts, and borders after PenPal connects. Call theme methods before importing media when possible.
These APIs affect UI chrome only (toolbar, panels, buttons, inputs, borders). They do not recolor the Konva timeline. Caption QC style guides (loadStyleGuide) and preview fonts (setPreviewFontFamily) remain separate.
For the full token contract, CSS examples, and customer-build checklist, see IFrame Theming.
Importing and Exporting Subtitles
The importSubtitle method loads a subtitle file from a URL into the editor. It accepts the file URL, a source profile identifying the format (for example "subRip" for SRT or "webVtt" for VTT), optional decode options specific to the format, and an optional Event Group options object for configuring real-time validation rules such as maxChars, maxLines, maxCps, and overlap. A complete list of supported source profiles is available at https://api.closedcaptionconverter.com/help/profiles/source.
By default importSubtitle creates a new Event Group. To import into an existing group instead, pass a target object as the seventh argument: { eventGroupId, importOption, track }. importOption accepts "replace" (default — swaps the group's events for the imported ones) or "merge" (appends the imported events to the group). When merging, the optional track value ("A"–"D") assigns every imported event to that track — useful for building multi-track groups such as dual-language or speaker-separated captions. For example, merging an SRT onto track B of an existing group:
await remote.importSubtitle(subtitleUrl, "subRip", null, {}, {}, false, {
eventGroupId: groupId,
importOption: "merge",
track: "B",
});
Loading two files onto separate tracks
To show two subtitle files side by side in one Event Group, create the group first and merge each file into it with its own track. The editor's list view then shows one column per track (see Event Group Tracks).
const group = await remote.addEventGroup({ name: "Dual Track", type: "subtitle" });
await remote.importSubtitle(englishUrl, "subRip", null, {}, {}, false, {
eventGroupId: group.id,
importOption: "merge",
track: "A",
});
await remote.importSubtitle(frenchUrl, "subRip", null, {}, {}, false, {
eventGroupId: group.id,
importOption: "merge",
track: "B",
});
await remote.selectEventGroupById(group.id);
const { tracks } = await remote.getSelectedEventGroupId(); // ["A", "B"]
Keep these rules in mind:
trackis applied only whenimportOptionis"merge". It is ignored whenimportSubtitlecreates a new group and when it replaces a group's events.importOptiondefaults to"replace", so a second import withoutimportOption: "merge"overwrites the first file.trackbelongs in thetargetobject (seventh argument), not in the Event Group options (fourth argument).- Merged events are appended after the group's existing events. They are not interleaved by time, so in the list view the second file's events appear below the first file's.
- Tracks do not apply to multiview Event Groups.
Naming and restricting tracks
Each Event Group can give its letter tracks custom names and limit which tracks end users can assign. Both settings appear in the Tracks section of the Edit Event Group and New Event Group modals, and both can be set from the parent page.
trackNamesis an object{ A, B, C, D }of strings. An empty string falls back to the default label ("Track A", "Track B", and so on). Names replace the letter labels everywhere the editor shows a track: event cards, Assign To Track, the Table View column, the track filter, and Export Tracks.availableTracksis an ordered subset of["A", "B", "C", "D"]. It defaults to all four. Pass[]to offer no letter tracks, leaving only No Track. The order sets the order tracks appear in pickers.
Set both when you create the group:
const group = await remote.addEventGroup({
name: "Deliverables",
type: "subtitle",
trackNames: { A: "Closed Captioning", B: "Forced Narrative" },
availableTracks: ["A", "B"],
});
Change them later with updateEventGroupTracks. It is a partial update: only the keys you pass change, and keys you leave out of trackNames keep their current value. availableTracks, when passed, replaces the whole list.
const result = await remote.updateEventGroupTracks(group.id, {
trackNames: { C: "Audio Description" },
availableTracks: ["A", "B", "C"],
});
// { success: true, trackNames: { A: "Closed Captioning", B: "Forced Narrative", C: "Audio Description", D: "" },
// availableTracks: ["A", "B", "C"] }
Read the settings, plus the tracks the group's events actually use, with getEventGroupTracks:
const { trackNames, availableTracks, usedTracks } = await remote.getEventGroupTracks(group.id);
getSelectedEventGroupId and getEventGroupInfo also return trackNames and availableTracks for each group.
How the restriction behaves:
- It applies across the editor UI: only available tracks are offered when users assign a track (Assign To Track, event card dropdowns, the Table View Track column, and keyboard shortcuts).
- Events already on a hidden track keep that track. They still display in their own column, can be filtered, and export normally. Users just can't newly assign a hidden track.
usedTrackscan therefore include letters missing fromavailableTracks. updateEventGroupTracksandgetEventGroupTracksreturn an error for an unknown Event Group ID or a multiview group.addEventGroupignores both keys for multiview groups.
API track parameters are not restricted. importSubtitle target.track, mergeEventGroups groupTracks, and exportSubtitle exportTracks accept any letter A–D whatever the group's availableTracks is, so the parent page can still place or export events on a track that end users can't pick.
The exportSubtitle method encodes captions into a target format. It accepts a target profile, optional encode options, a saveAsFile boolean, an optional forcedOption, an optional eventGroupId, and an optional exportTracks array. When eventGroupId is omitted, the currently selected Event Group is exported. exportTracks (default ["none", "A", "B", "C", "D"]) limits the export to events on the listed tracks, where "none" matches events without a track assignment — pass ["B"], for example, to export only track B. Use getEventGroupInfo or getSelectedEventGroupId to discover which tracks a group uses via their tracks field, and which BCP-47 language tag to stamp on published files. When saveAsFile is false, the method returns the encoded file contents as a string so the parent application can handle delivery — for example, uploading the result to cloud storage or posting it to an API. When saveAsFile is true, a browser file download is triggered instead.
The mergeEventGroups method combines multiple Event Groups into a new group. Its optional fourth argument, groupTracks, maps source group IDs to track letters (for example { [groupAId]: "A", [groupBId]: "B" }) so each source group's events land on a dedicated track in the merged result.
Quality Control Workflows
Custom style guides can be loaded into the editor programmatically using loadStyleGuide, which accepts a style guide configuration object defining rules such as maximum characters per second, maximum duration, minimum event gap, and a range of text formatting checks. Once a style guide is loaded, qcEventGroup runs validation against a specified Event Group and returns all errors found, including error counts and the relevant event data. This enables the parent application to gate the publish action — preventing delivery until caption quality meets the configured standard — and to surface specific errors to the editor using the status modal functions.
Troubleshooting
The most common setup issue is an allowedOrigins mismatch. In production, the allowedOrigins array in the Penpal.WindowMessenger configuration must specify the exact origin of the IFrame — https://iframe-demo.closedcaptioncreator.com — rather than the wildcard '*' used in development. Using '*' in a production environment is a security risk and may also cause connection failures in certain browsers.
If the editor does not respond to method calls after the connection is established, confirm that the allow="clipboard-write; clipboard-read; encrypted-media" attribute is present on the <iframe> tag. Missing permissions prevent certain editor features from functioning and can cause the initialisation sequence to stall.
If importMedia or importSubtitle returns { success: false, message: "Failed to fetch" }, the file's host is not allowing the request. Media and subtitle URLs are fetched by the editor running in the iframe, not by your page, so the host must send CORS headers that allow the iframe origin, and cookies for your own domain are not sent. Use public or pre-signed URLs. When a URL has a query string, such as a signed cloud storage URL, always pass the profile argument to importSubtitle. Without it the format is guessed from the URL's file extension, which fails on query strings.
Exports from trial accounts and demo builds, including the public iframe-demo origin, replace every event after the halfway point with "TRIAL VERSION". Test export output on your licensed build.
If the PenPal connection times out before your setup code runs, ensure that Penpal.connect is called inside a load event listener on the iframe element rather than immediately after the iframe is added to the DOM. The connection should only be initiated once the iframe's content window is fully loaded.
For developer support and integration assistance, visit the Contact Page to connect with the Closed Caption Creator team.