Skip to main content
VideoField ← Back to Table of Contents

Summary

Custom video player with optional YouTube embed, skip controls, PiP, fullscreen, and compact control layout.
ClassBjanczak\FilamentFlexFields\Filament\Forms\Components\VideoField
State typestring|null — video URL or YouTube link
FieldTypevideo

Basic usage

use Bjanczak\FilamentFlexFields\Filament\Forms\Components\VideoField;

VideoField::make('trailer_url')
    ->label('Trailer')
    ->ratio('16:9')
    ->title('Product trailer')
    ->controls()
    ->allowYoutube();

VideoField::make('tutorial')
    ->src('https://cdn.example.com/tutorial.mp4')
    ->poster('/images/tutorial-poster.jpg')
    ->skipSeconds(15)
    ->pictureInPictureable()
    ->compactControls();
YouTube URL in state:
VideoField::make('promo_video')
    ->default('https://www.youtube.com/watch?v=dQw4w9WgXcQ')
    ->youtubeNoCookie()
    ->autoHideControls();

State format

ModeBehaviour
DefaultState string = direct video URL or YouTube URL
src() setStatic URL overrides state for playback
YouTubeDetected via VideoSources::youtubeId() when allowYoutube()

Validation

RuleDetail
nullableState may be empty
stringState must be string when present

Configuration API

allowVimeo(bool|Closure $condition = true)

Enables or disables parsing of Vimeo URLs and loading of Vimeo player embeds. Default is true.
VideoField::make('trailer')
    ->allowVimeo(false); // Only allow YouTube/HTML5 sources

Public helper methods

MethodReturnsDescription
getControlsLayout()stringdefault or compact
usesCompactControls()boolCompact layout
getRatio() / getAspectRatioStyle()string|nullAspect ratio
resolveVideoSrc(mixed $state)string|nullEffective URL
resolveYoutubeId(mixed $state)string|nullYouTube video ID
usesYoutubeEmbed(mixed $state)boolYouTube mode
resolveProvider(mixed $state)stringhtml5, youtube, etc.
resolveYoutubeEmbedUrl(...)string|nullEmbed URL
usesYoutubeCustomControls(mixed $state)boolCustom YT chrome
usesYoutubeFacade(mixed $state)boolClick-to-play facade
getYoutubeIframePlayerVars(...)arrayiframe playerVars
resolveYoutubeThumbnail(mixed $state)string|nullPoster/thumbnail
supportsPictureInPicture(mixed $state)boolPiP available
hasMetadata()boolTitle or subtitle set
shouldShowControls() etc.boolFeature flags
getSkipSeconds()intSkip interval

FlexField schema config

Config keyMaps to
sizesize()
ratioratio()
full_widthfullWidth()
srcsrc()
poster / placeholderposter()
titletitle()
subtitlesubtitle()
controlscontrols()
native_controlsnativeControls()
autoplayautoplay()
looploop()
mutedmuted()
plays_inlineplaysInline()
skip_secondsskipSeconds()
picture_in_picturepictureInPictureable()
allow_youtubeallowYoutube()
youtube_no_cookieyoutubeNoCookie()
auto_hide_controlsautoHideControls()
controls_layoutcontrolsLayout()

CSS classes

ClassRole
fff-video-field-fieldRoot wrapper
fff-video-field-field--{sm|md|lg}Size modifier
fff-video-field__stageVideo area
fff-video-field__controlsControl bar
fff-video-field__controls--compactCompact layout

Implementation notes

  • YouTube with custom controls uses iframe API; facade mode shows thumbnail until play.
  • Invalid ratio strings throw InvalidArgumentException.