Working with Videos
Videos in Val
Videos in Val are handled using the s.file() schema with accept: 'video/*'. This provides type-safe video handling with support for local and remote videos.
Defining Video Schema
Use s.file({ accept: 'video/*' }) to define a video field. Val Studio will automatically render it with a video preview:
Adding Video Content
Videos must be stored in the /public/val folder. Use c.file() to reference them with proper metadata:
Rendering Videos
Access the video URL using the .url property and render it with standard HTML5 video elements:
Basic video rendering
Advanced Video Controls
For more control over video playback, you can add additional HTML5 video attributes:
Video with autoplay and loop
Video Attributes Explained
Common video attributes:
controls- Shows play, pause, and volume controlsautoPlay- Starts playing automatically (usually requiresmuted)muted- Mutes the video (required for autoplay on most browsers)loop- Restarts the video when it endsplaysInline- Plays inline on mobile devices instead of fullscreenpreload='metadata'- Loads only video metadata to save bandwidth
Remote Videos
For large video files, you can use remote storage. Enable remote videos by adding .remote() to your schema. See the Remote Files guide for details on setup and uploading.
Remote video example
NOTE: Future Streaming Support
Val currently serves videos as regular file downloads. Support for optimized video streaming and adaptive bitrate streaming may be added in a future release for better performance and user experience.