3 namespace Drupal\media\Plugin\media\Source;
5 use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
6 use Drupal\media\MediaTypeInterface;
9 * Media source wrapping around an audio file.
11 * @see \Drupal\file\FileInterface
15 * label = @Translation("Audio file"),
16 * description = @Translation("Use audio files for reusable media."),
17 * allowed_field_types = {"file"},
18 * default_thumbnail_filename = "audio.png"
21 class AudioFile extends File {
26 public function createSourceField(MediaTypeInterface $type) {
27 return parent::createSourceField($type)->set('settings', ['file_extensions' => 'mp3 wav aac']);
33 public function prepareViewDisplay(MediaTypeInterface $type, EntityViewDisplayInterface $display) {
34 $display->setComponent($this->getSourceFieldDefinition($type)->getName(), [
35 'type' => 'file_audio',