Div video components: turning AI JSON specs into native SwiftUI players
AI-generated UI is increasingly sending div video components in JSON instead of plain text links, and the fastest way to turn those specs into a polished iOS…

AI-generated UI is increasingly sending div video components in JSON instead of plain text links, and the fastest way to turn those specs into a polished iOS experience is to map them onto native SwiftUI video players under a server-validated contract.
In practice, that means: the agent emits a structured div video block; your backend validates it; and your app renders it as a SwiftUI VideoPlayer powered by AVPlayer, with autoplay, controls, and analytics entirely under your control.
This article breaks down what those div video blocks represent, when AI agents will use them, and how Uzori-style contracts keep your iOS video UX native, safe, and measurable.
What is a div video block in generative UI JSON?
A div video block is a declarative description of a video element in a generative UI JSON schema.
In systems like DivKit, it’s not executable code; it’s a data structure that says “there is a video here with these sources and playback rules.”
Typical fields in a DivKit-style video element include:
video_sources: one or more URLs or IDs for streamable mediapreview: poster frame or thumbnail shown before playbackautostart: whether playback should begin automaticallymuted: whether audio is initially mutedrepeatable: loop behavior for the videoplayback_speed: optional speed control hintselapsed_time_variable: a variable to track progressplayer_settings_payload: structured, player-specific options
These properties match DivKit’s documented schema for video components and provide a compact, machine-readable description of how a video should behave.
Div video block JSON schema: structure over chaos
The Div video block JSON schema is an example of the broader industry trend: schema-constrained generative UI.
Projects like A2UI define catalogs where:
- Components are declared up front (cards, forms, video, etc.)
- JSON payloads must validate against that catalog
- Renderers map each component type onto native widgets
This “closed catalog + validation” pattern ensures AI agents can’t invent arbitrary new primitives at runtime.
For iOS teams, that means:
- You keep control over what “video” means in your app
- You decide which playback options are exposed in the contract
- You can enforce autoplay, mute, and analytics policies centrally
When will AI agents emit div video components?
AI agents emit div video components when they need to present video as a first-class UI element instead of as a bare link or text.
Common scenarios include:
- Media-rich recommendations: product video demos, walkthroughs, or trailers
- Guided flows: onboarding steps with embedded explainer clips
- Content browsing: feeds or carousels mixing images, text, and video tiles
- Support and troubleshooting: step-by-step repair or setup videos
Instead of replying with:
"Here’s a video you should watch: https://example.com/video.mp4"
An AI agent with a generative UI contract can respond with JSON like:
{
"type": "video",
"video_sources": [
{ "url": "https://cdn.example.com/plan-explainer.m3u8" }
],
"preview": {
"url": "https://cdn.example.com/plan-explainer-poster.jpg"
},
"autostart": false,
"muted": false,
"repeatable": false,
"analytics_id": "plan-explainer-2026-q4"
}
In an Uzori-style flow, your backend validates that payload against your schema, then your iOS app renders it with native SwiftUI controls.
LLM emits video block when include video content
From an LLM’s perspective, a video block is emitted whenever the model decides that:
- Video is the best way to fulfill a request (e.g., “show me how to swap my SIM”)
- Your catalog says there is a
videocomponent available - The agent has access to compatible
video_sourcesfrom your backend
Because catalogs like A2UI’s constrain the model’s choices, the LLM doesn’t invent HTML or custom players.
It chooses between:
div image/div textfor static contentdiv videofor playable content- Other components (forms, lists, comparison views) depending on the task
This keeps the model focused on layout and orchestration, not rendering details.
Mapping div JSON video to native SwiftUI video experiences
The key step for iOS teams is turning a Div-style JSON spec into a SwiftUI video experience that feels indistinguishable from the rest of your app.
Here’s the high-level mapping:
- JSON
video_sources→AVPlayerItem/AVPlayer - JSON
preview/poster→ SwiftUIImageoverlay or placeholder - JSON
autostart/muted/repeatable→ playback policy configuration - JSON
elapsed_time_variable→ SwiftUI state bound to AVFoundation observation - JSON
analytics_id→ custom analytics events and metrics logging
Turn LLM response into SwiftUI VideoPlayer
At render-time inside your app, a simple pattern looks like this:
struct AgentVideoView: View {
let spec: AgentVideoSpec // parsed from validated JSON
@State private var player: AVPlayer? = nil
var body: some View {
VideoPlayer(player: player) {
// videoOverlay for controls or labels
if let preview = spec.previewImage {
preview
.resizable()
.scaledToFit()
}
}
.onAppear {
configurePlayer()
}
}
private func configurePlayer() {
guard let url = spec.primarySourceURL else { return }
let item = AVPlayerItem(url: url)
let avPlayer = AVPlayer(playerItem: item)
// Apply muted / autoplay from spec within your policy
avPlayer.isMuted = spec.muted
player = avPlayer
if spec.autostart && canAutoplay(spec) {
avPlayer.play()
}
}
private func canAutoplay(_ spec: AgentVideoSpec) -> Bool {
// Your business logic: connectivity, user settings, etc.
return false
}
}
Apple’s VideoPlayer view provides native playback UI and an overlay for additional controls.
AVFoundation’s playback observation APIs let you track progress and quality metrics in SwiftUI state, matching the structured fields in your JSON.
Uzori server-validated contracts: keeping video behavior safe
Uzori’s approach revolves around server-validated contracts: the AI composes UI, but your backend validates every screen before it reaches the user.
For video, that means:
- Agents can request autoplay, mute, or repeatable behavior
- Your server decides whether those options are allowed per context
- The iOS client renders only approved video specs
Uzori server-validated contracts for video
A typical contract for video components might define:
- Allowed fields:
video_sources,preview,autostart,muted,repeatable,analytics_id - Value constraints:
autostartcan betrueonly for short, non-intrusive clipsmutedmust betruewhenautostartistruevideo_sourcesmust point to whitelisted CDNs or signed URLs
Every AI UI response passes through:
- Schema validation: does the JSON match the catalog’s video component?
- Policy checks: are autoplay/mute/repeat within your rules?
- Sanitization: resolve IDs to real URLs, attach analytics IDs, etc.
Only then does Uzori stream the SwiftUI screen spec to your app.
Because 40% of enterprise apps are predicted to feature task-specific AI agents by 2026 (up from <5% in 2025), this kind of server-driven safety is not optional—it’s the pattern that keeps generative video flows shippable.
Uzori SDK video autoplay controls and policies
One of the biggest concerns with AI-generated video UI is autoplay.
Native users expect predictable behavior, and platforms evolve cultural norms on sound, data usage, and attention.
With an Uzori-style contract, you treat autoplay as a policy decision, not an AI suggestion.
Disable autoplay in iOS SwiftUI video
Even if an AI agent sets autostart: true in the JSON, your stack can enforce:
- Global autoplay disabled setting based on user preferences
- Network-aware policies (e.g., autoplay only on Wi‑Fi)
- Content-specific rules (e.g., no autoplay for long-form video)
In SwiftUI, that looks like:
if spec.autostart && autoplayPolicy.allows(spec) {
avPlayer.play()
} else {
// render paused state with poster frame
}
The contract ensures the client code never blindly trusts model output.
Your team owns the final decision point between spec and playback.
Poster frames and overlay UX for AI-generated video blocks
A poster frame for AI-generated video blocks (JSON preview or posterUrl) is critical for smooth UX.
Instead of jumping directly into playback, you show a still image that:
- Fits your design system (rounded corners, shadows, etc.)
- Communicates duration, title, or content type
- Aligns with your “Div on image” overlay patterns
For deeper overlay-heavy patterns—labels, badges, and stacked controls over media—you can lean on the guidance in descriptive anchor text.
Div on image, div images, div video, div text, div data
In a mature catalog, you’ll typically see a small set of media primitives:
div image: static images, avatars, thumbnailsdiv text: titles, captions, supporting descriptionsdiv data: structured labels such as duration, resolution, or ratingdiv video: playable content blocks that combine all of the above
The AI agent orchestrates these blocks to build rich rows, cards, and carousels.
Your renderer simply maps them to native SwiftUI:
Image,Text, stacks, and overlaysVideoPlayerandAVPlayerfor playback- Your own reusable components for consistent branding
SwiftUI VideoPlayer: customize controls and analytics
Apple’s VideoPlayer gives you a native playback UI out of the box, but modern generative UI flows increasingly need custom controls and analytics for in-app video playback on iOS.
Uzori-style contracts make those extensions predictable.
SwiftUI VideoPlayer customize controls
You can layer custom UI on top of VideoPlayer using videoOverlay:
VideoPlayer(player: player) {
VStack {
Spacer()
HStack {
Text(spec.title)
Spacer()
Text(spec.durationLabel)
}
.padding()
}
}
With a structured contract, the agent can specify:
- Title and metadata to show in the overlay
- High-level layout hints (e.g., “label bottom-left”)
- Actions to expose (play/pause, replay, next video)
You still implement controls with native SwiftUI components and bind them to AVPlayer.
Analytics for in-app video playback iOS
AVFoundation exposes playback state observation and media-performance metrics you can tie to analytics IDs from the JSON spec.
You can log events such as:
video_startedwithanalytics_id, timestamp, and network conditionsvideo_completedwith playback duration and seek behaviorvideo_abandonedwith position and reason (error, user back navigation)
This is especially important in the context of AI agents.
With 65% of staff-level developers already delegating tasks to agents, having structured, reviewable analytics around what those agents are serving helps teams tune catalogs, policies, and UI behavior over time.
How Uzori bridges generative JSON and native SwiftUI video
Uzori positions itself at the convergence of generative UI and server-driven UI for iOS.
For video components, that bridge looks like:
- Catalog definition: your backend defines a
videocomponent with allowed fields and constraints. - Agent orchestration: the AI uses that component when building flows with video (e.g., product explorers, plan explainers).
- Server validation: JSON specs are checked against the catalog and your video policies.
- SwiftUI rendering: your app uses Uzori’s iOS SDK to receive a valid screen spec and instantiate
VideoPlayer-backed views.
The result: users experience AI-powered video flows that feel like your app—not like a pasted-in chatbot.
You keep:
- Native first UI: SwiftUI, AVKit, and your design system
- Structure over chaos: typed, server-authored contracts
- AI as interface: agents orchestrate flows rather than just text blocks
Teams interested in trying this approach can explore the SDK and architecture details at uzori.ai.
FAQ: div video blocks and SwiftUI players
1. How do I validate AI UI responses with video on the server?
You define a JSON schema or catalog where type: "video" components list the fields you permit (video_sources, preview, autostart, etc.).
Each agent response is validated against that schema, and you apply additional policy checks to enforce autoplay and source whitelisting before streaming the spec to the client.
2. Can I turn a div JSON video spec into a custom SwiftUI player instead of VideoPlayer?
Yes.
Your renderer doesn’t have to use VideoPlayer—it can map the video spec to any combination of SwiftUI views and AVPlayer controls, such as custom overlay bars, gesture handling, or subtitles.
The important part is keeping the mapping stable and well-typed so that changes to the contract don’t break rendering.
3. How do I disable autoplay globally even if the AI requests it?
Treat autostart as a request, not a command.
Implement an autoplayPolicy layer in your backend or client, and guard all play() calls with that policy.
This lets you centrally enforce region-specific rules, user preferences, and data-usage constraints without changing the AI agent.
4. What’s the difference between div video and embedding a web player?
A div video block represents a native UI primitive controlled by your app—mapped to VideoPlayer and AVPlayer on iOS.
Embedding a web player or iframe delegates rendering and behavior to remote code, which is harder to control, less accessible, and less aligned with your design system.
Schema-constrained div video blocks keep playback native and predictable.
5. How do I combine div images and div video in a single SwiftUI layout?
Use your catalog to describe composite components: cards, rows, or carousels that mix image, text, data, and video.
In SwiftUI, you compose those blocks with HStack, VStack, ZStack, and overlays, rendering images and text using your standard components and videos using VideoPlayer.
Because the JSON is structured, the AI can orchestrate complex layouts without you having to write bespoke UI code for each flow.