It has long been possible to upload rich media into file fields, including audio (e.g., MP3, OGG, WAV, etc.) and video (e.g. MP4, MOV, AVI, etc.) However, core has had no support for displaying such media in using the standard <audio> and <video> HTML tags.
#1174892: File field formatters for rich media display with <video> and <audio> HTML5 elements. introduces two new formatters to the File module: file_audio and file_video, supporting the <audio> and <video> tags, respectively. Both formatters extend a new base class, Drupal\file\Plugin\Field\FieldFormatter\FileMediaFormatterBase, which provides generic settings applicable to both the <audio> and <video> tags, such as "show playback controls", "autoplay", "loop", and so forth.
The base class implements an interface, Drupal\file\Plugin\Field\FieldFormatter\FileMediaFormatterInterface, which defines a single method to ensure that the implementing formatter is only applicable to certain MIME types. Currently, only the new audio and video formatters implement this interface, or extend the base class.
New classes and interfaces
Drupal\file\Plugin\Field\FieldFormatter\FileMediaFormatterBaseDrupal\file\Plugin\Field\FieldFormatter\FileMediaFormatterInterfaceDrupal\file\Plugin\Field\FieldFormatter\FileAudioFormatterDrupal\file\Plugin\Field\FieldFormatter\FileVideoFormatter