Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Active Storage: displaying video in video_tag

In a Rails 5.2 app, I want to display a video previously uploaded in S3 via Active Storage. When I use this:

<%= video_tag [@banner_video.video_mp4, @banner_video.video_webm] %>

I get this error:

The asset "" is not present in the asset pipeline.

I checked in console, and my variable @banner_video is exactly what I think it should be.

like image 424
Ruff9 Avatar asked Jun 22 '18 17:06

Ruff9


2 Answers

2 variants that I used to make it work

  1. <%= video_tag url_for(@banner_video.file), size: "150x120", controls: true %>

or with to get S3 url

  1. <%= video_tag @banner_video.file.service_url, size: "150x120", controls: true %>
like image 124
Игорь Хлебников Avatar answered Sep 19 '22 20:09

Игорь Хлебников


I found a solution not using video_tag, with a little hack.

<video>
  <source src=<%= rails_blob_path(@banner_video.video_mp4) %> type="video/mp4" />
  <source src=<%= rails_blob_path(@banner_video.video_webm) %> type="video/webm" />
</video>

This is working, looks like video_tag is not handling remote sources.

like image 34
Ruff9 Avatar answered Sep 21 '22 20:09

Ruff9