AudioFile.php in Drupal 9
File
core/modules/media/src/Plugin/media/Source/AudioFile.php
View source
<?php
namespace Drupal\media\Plugin\media\Source;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\media\MediaTypeInterface;
class AudioFile extends File {
public function createSourceField(MediaTypeInterface $type) {
return parent::createSourceField($type)
->set('settings', [
'file_extensions' => 'mp3 wav aac',
]);
}
public function prepareViewDisplay(MediaTypeInterface $type, EntityViewDisplayInterface $display) {
$display
->setComponent($this
->getSourceFieldDefinition($type)
->getName(), [
'type' => 'file_audio',
'label' => 'visually_hidden',
]);
}
}
Classes
Name |
Description |
AudioFile |
Media source wrapping around an audio file. |