1
votes

I m trying to implement some upload then play video in my app using Rails 5.2.3 and Active Storage. After fighting with active storage for a while i m finally sure that my attachment is containing the file i want to attach => after inspecting the src is correct The problem here is that i keep getting those warnings from firefox console :

HTTP "Content-Type" of "text/html" is not supported. Load of media resource http://localhost:3000/rails/active_storage/blobs/eyJfcmFpbHM…JibG9iX2lkIn19--a44730f58a07282f626737b6a541d57fa9dc11c4/vid failed. 23 Cannot play media. No decoders for requested formats: text/html

and a video area with the following message "
No video with supported format and MIME type found"

Now, the console warnings are only showing up in Firefox but the video isn't playable in all the browsers that i tested so i think that my problem got something to do with the warning. I m new to rails so i ve tried all what i have found in google without solving my problem.

I m showing the video with the video_tag this way :

 <%= video_tag(url_for(@play.clip), style: "width:100%;height:auto", :controls => true) if @play.clip.attached? %>

And added a meme_types.rb in initializers with the following code

Rack::Mime::MIME_TYPES.merge!({
                                ".mp4" => "video/mp4",
                              })

I have tried to display the video using plain html5 ( which is the same) and i m naturally getting the same warnings...

1
It looks like the URL you are providing as source is not a video, or at least isn't recognized as one. The url apparently ends with a '/vid' So, 2 questions: What is the output of url_for(@play.clip)? Have you tried just video_tag( @video.clip ) ? - Zavitoski
to your questions : 1- url_for(@play.clip) result is rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBJQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--a44730f58a07282f626737b6a541d57fa9dc11c4/vid 2- i get " The asset "" is not present in the asset pipeline." I don't think it comes from the extension.Already tried a workaround to add the extension in the url but that wasn't the problem - pride
Could you please provide a little more code then? Like the Play model. - Zavitoski
@Zavitoski: replied in the comment - pride

1 Answers

1
votes

fixed. The issue wasn't coming from the active storage itself. The get request to play the video was stopped by a line i wrote in routes.rb to make all "unknown routes" redirect to root_path :

get '*path' => redirect('/')

Now t hat the video playing video has been fixed i have to deal with "redirecting unknown paths to root without causing a problem with the GET "