7

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.

Ruff9
  • 1,163
  • 15
  • 34
  • I guess your question is duplicate.Take a look at this : https://stackoverflow.com/questions/46020753/the-asset-logo-png-is-not-present-in-the-asset-pipeline – Afsanefda Jun 22 '18 at 18:10
  • No, the video is not in the asset pipeline, it's hosted on a remote S3 bucket. I displayed images with no pb. – Ruff9 Jun 22 '18 at 18:41
  • Oh you are right. – Afsanefda Jun 22 '18 at 18:42
  • @Ruff9 how ur uploading into cloud ? what do u use? – 7urkm3n Jun 22 '18 at 20:26
  • I did setup an ActiveAdmin interface, and a form with a file type field... my app is connected to my S3 bucket via Active Storage, and it works like a charm for images. – Ruff9 Jun 23 '18 at 03:55

4 Answers4

3

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 %>
fguillen
  • 36,125
  • 23
  • 149
  • 210
2

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.

Ruff9
  • 1,163
  • 15
  • 34
  • In what might be considered vital if you don't know the content type, it's not necessary to render the video. – t56k Jul 27 '18 at 03:43
  • 1
    This works as well: <%= video_tag rails_blob_path(session.video) %> – Metaphysiker Sep 15 '18 at 11:38
  • 1
    Have you been able to play the video. I can only have the preview appear, which is the first frame of the video only. I want it to actually play... – uno Mar 10 '19 at 23:43
  • 1
    <%= video_tag rails_blob_path(session.video), controls: true %>. **controls: true** make you able to preview. – Montells May 20 '19 at 15:51
2

From @Methaphysiker comment:

<%= video_tag rails_blob_path(@banner_video.video_mp4) %>
fguillen
  • 36,125
  • 23
  • 149
  • 210
1

As said @metaphysiker This works as well: <%= video_tag rails_blob_path(session.video) %>

Jaycreation
  • 2,029
  • 1
  • 15
  • 30