- How do I add a media preview action to a Filament table?
- Use `MediaAction::make('label')` in your table’s `actions()` method, then pass the media URL via `->media('URL')`. The package auto-detects the file type and renders the correct player. Example: `MediaAction::make('Preview')->media($record->media_url)`.
- Does this package support YouTube/Vimeo embeds?
- Yes, it supports YouTube embeds (pass the full URL) and will auto-detect and render them. Vimeo requires a custom player or URL parsing via `->mediaType()` if not auto-detected. For Vimeo, use `->mediaType(MediaAction::TYPE_VIDEO)->media('VIMEO_URL')`.
- Will this work with Filament v5? What’s the installation command?
- Yes, it’s fully compatible with Filament v5. Install via `composer require hugomyb/filament-media-action:^5.0`. The package auto-detects your Filament version and aligns its behavior accordingly. No manual version checks are needed.
- How do I handle local media files (e.g., from storage) without extensions?
- Force the media type using `->mediaType()` before passing the URL. For example, `->mediaType(MediaAction::TYPE_VIDEO)->media(storage_path('video.mp4'))`. This bypasses auto-detection for unsupported local files. Always ensure MIME headers are correct for seamless playback.
- Can I customize the media player UI (e.g., remove controls, add autoplay)?
- Yes, use the `->options()` method to pass HTML5 media attributes. Example: `->options(['autoplay', 'muted', 'controlsList' => 'nodownload'])` for muted autoplay without download buttons. For advanced customization, publish the views and override the Blade templates.
- Does this package work with Spatie Media Library or Laravel Mix?
- Absolutely. Pass the media URL from Spatie (e.g., `$record->getFirstMediaUrl()`) or Laravel Mix assets directly. The package treats all URLs uniformly, so no additional integration is required. Just ensure the URL is publicly accessible.
- How do I lazy-load media actions in large tables (e.g., 1000+ rows)?
- Use Filament’s built-in pagination or lazy-loading for tables. The package itself doesn’t preload media—it only renders the player on demand when the action is clicked. For performance, consider adding `->preload(false)` to disable preloading large files.
- What if autoplay is blocked by the browser? How can I ensure compliance?
- Autoplay is muted by default to comply with browser policies. Use `->options(['autoplay', 'muted'])` for silent autoplay. For user-triggered playback, omit `autoplay` and rely on the play button. Test in Firefox/Safari, as their autoplay policies are stricter than Chrome.
- Can I use this in Filament forms or infolists, not just tables?
- Yes, `MediaAction` works anywhere Filament actions are supported: tables, forms, infolists, and even as suffix/prefix actions. For forms, use it in `->actions()` or `->columns()`. Example: `TextInput::make('media')->action(MediaAction::make('Preview')->media($record->media_url))`.
- Are there alternatives if I need Vimeo or custom PDF viewers?
- For Vimeo, use `->mediaType(MediaAction::TYPE_VIDEO)->media('VIMEO_URL')` with a custom player URL. For PDFs, the package uses a default viewer, but you can publish the views and replace the Blade template with a library like `pdf.js`. Alternatives like `laravel-media-library` offer broader format support but lack Filament integration.