VideoFile.php

Same filename in other branches
  1. 9 core/modules/media/src/Plugin/media/Source/VideoFile.php
  2. 8.9.x core/modules/media/src/Plugin/media/Source/VideoFile.php
  3. 10 core/modules/media/src/Plugin/media/Source/VideoFile.php

Namespace

Drupal\media\Plugin\media\Source

File

core/modules/media/src/Plugin/media/Source/VideoFile.php

View source
<?php

namespace Drupal\media\Plugin\media\Source;

use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\media\Attribute\MediaSource;
use Drupal\media\MediaTypeInterface;

/**
 * Media source wrapping around a video file.
 *
 * @see \Drupal\file\FileInterface
 */
class VideoFile extends File {
    
    /**
     * {@inheritdoc}
     */
    public function createSourceField(MediaTypeInterface $type) {
        return parent::createSourceField($type)->set('settings', [
            'file_extensions' => 'mp4',
        ]);
    }
    
    /**
     * {@inheritdoc}
     */
    public function prepareViewDisplay(MediaTypeInterface $type, EntityViewDisplayInterface $display) {
        $display->setComponent($this->getSourceFieldDefinition($type)
            ->getName(), [
            'type' => 'file_video',
            'label' => 'visually_hidden',
        ]);
    }

}

Classes

Title Deprecated Summary
VideoFile Media source wrapping around a video file.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.