You are here

class AudioFile in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/media/src/Plugin/media/Source/AudioFile.php \Drupal\media\Plugin\media\Source\AudioFile
  2. 9 core/modules/media/src/Plugin/media/Source/AudioFile.php \Drupal\media\Plugin\media\Source\AudioFile

Media source wrapping around an audio file.

Plugin annotation


@MediaSource(
  id = "audio_file",
  label = @Translation("Audio file"),
  description = @Translation("Use audio files for reusable media."),
  allowed_field_types = {"file"},
  default_thumbnail_filename = "audio.png"
)

Hierarchy

Expanded class hierarchy of AudioFile

See also

\Drupal\file\FileInterface

File

core/modules/media/src/Plugin/media/Source/AudioFile.php, line 21

Namespace

Drupal\media\Plugin\media\Source
View source
class AudioFile extends File {

  /**
   * {@inheritdoc}
   */
  public function createSourceField(MediaTypeInterface $type) {
    return parent::createSourceField($type)
      ->set('settings', [
      'file_extensions' => 'mp3 wav aac',
    ]);
  }

  /**
   * {@inheritdoc}
   */
  public function prepareViewDisplay(MediaTypeInterface $type, EntityViewDisplayInterface $display) {
    $display
      ->setComponent($this
      ->getSourceFieldDefinition($type)
      ->getName(), [
      'type' => 'file_audio',
      'label' => 'visually_hidden',
    ]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AudioFile::createSourceField public function Creates the source field definition for a type. Overrides File::createSourceField
AudioFile::prepareViewDisplay public function Prepares the media type fields for this source in the view display. Overrides MediaSourceBase::prepareViewDisplay
DependencySerializationTrait::$_entityStorages protected property
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function 2
DependencySerializationTrait::__wakeup public function 2
File::getMetadata public function Gets the value for a metadata attribute for a given media item. Overrides MediaSourceBase::getMetadata 1
File::getMetadataAttributes public function Gets a list of metadata attributes provided by this plugin. Overrides MediaSourceInterface::getMetadataAttributes 1
File::getThumbnail protected function Gets the thumbnail image URI based on a file entity.
File::METADATA_ATTRIBUTE_MIME constant Key for "MIME type" metadata attribute.
File::METADATA_ATTRIBUTE_NAME constant Key for "Name" metadata attribute.
File::METADATA_ATTRIBUTE_SIZE constant Key for "File size" metadata attribute.
MediaSourceBase::$configFactory protected property The config factory service.
MediaSourceBase::$entityFieldManager protected property The entity field manager service.
MediaSourceBase::$entityTypeManager protected property The entity type manager service.
MediaSourceBase::$fieldTypeManager protected property The field type plugin manager service.
MediaSourceBase::$label protected property Plugin label.
MediaSourceBase::buildConfigurationForm public function 2
MediaSourceBase::calculateDependencies public function
MediaSourceBase::create public static function 2
MediaSourceBase::createSourceFieldStorage protected function Creates the source field storage definition.
MediaSourceBase::defaultConfiguration public function 2
MediaSourceBase::getConfiguration public function
MediaSourceBase::getSourceFieldDefinition public function
MediaSourceBase::getSourceFieldName protected function Determine the name of the source field. 2
MediaSourceBase::getSourceFieldOptions protected function Get the source field options for the media type form.
MediaSourceBase::getSourceFieldStorage protected function Returns the source field storage definition.
MediaSourceBase::getSourceFieldValue public function
MediaSourceBase::prepareFormDisplay public function 3
MediaSourceBase::setConfiguration public function
MediaSourceBase::submitConfigurationForm public function 1
MediaSourceBase::validateConfigurationForm public function 1
MediaSourceBase::__construct public function Constructs a new class instance. 2
MediaSourceInterface::METADATA_FIELD_EMPTY constant Default empty value for metadata fields.
MessengerTrait::$messenger protected property The messenger. 18
MessengerTrait::messenger public function Gets the messenger. 18
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition.
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function
PluginBase::getDerivativeId public function
PluginBase::getPluginDefinition public function 2
PluginBase::getPluginId public function
PluginBase::isConfigurable public function Determines if the plugin is configurable.
StringTranslationTrait::$stringTranslation protected property The string translation service. 3
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 1
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.