Why cannot I get the path of a video? I can't manage to get the video link of a media, I can achieve this with a picture but with videos it doesn't work.

This is the code I am using.

function slider_get_uri_by_media($media, $style = 'background'){
  // kint(isset($media-&gt;file_media_video_file));
  if (isset($media-&gt;field_media_image)){
    $file = $media-&gt;field_media_image-&gt;entity;
    if ($file &amp;&amp; $fid = $file-&gt;id()) {
      $image = File::load($fid);
      if ($image_style = ImageStyle::load($style)) {
        return ['url' =&gt; file_url_transform_relative($image_style-&gt;buildUrl($image-&gt;getFileUri()))];
      }
    }
  }
  elseif (isset($media-&gt;file_media_video_file)) {
    $file = $media-&gt;file_media_video_file-&gt;entity;
    if ($file &amp;&amp; $fid = $file-&gt;id()) {
      $video = File::load($fid);
    }
  }
}


Why cannot I get the path for the video stored in $media-&gt;field_media_video_file?
I think that you have a typo in the field name, you should replace 
$media-&gt;file_media_video_file 
with 
$media-&gt;field_media_video_file (2 times)