Skip to content

Commit

Permalink
[~] update README for autoplay method
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomyb committed Sep 25, 2024
1 parent 09378df commit 6f2a208
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,28 @@ MediaAction::make('tutorial')

### Available options

#### Autoplay

You can enable autoplay for video and audio by using the `->autoplay()` method.

```php
MediaAction::make('media-url')
->media(fn($record) => $record->url)
->autoplay()
```

You can also pass a closure in the method and access `$record` and `$mediaType` :

```php
MediaAction::make('media-url')
->media(fn($record) => $record->url)
->autoplay(fn($record, $mediaType) => $mediaType === 'video')
```

`$mediatype` can return "youtube", "audio", "video", "image" or "pdf".

#### Other options

You can customize the modal as you wish in the same way as a classic action (see https://filamentphp.com/docs/3.x/actions/modals).

If there is an existing record, you can access it by passing a closure to `->media()` method.
Expand Down

0 comments on commit 6f2a208

Please sign in to comment.