Alex Le
Alex Le

Reputation: 31

Video not playing in Rails

I'm having trouble loading a video into my view in Rails. I'm using the video_tag helper like so:

<%= video_tag "BigBuckBunny.mp4", :size => "600x400", :controls => true %>

I have my application.rb file configured like so:

config.assets.paths << "#{Rails.root}/app/assets/videos"

See: HTML5 VIDEO is not working in my rails 3 app

The video file is located under 'app/assets/videos/BigBuckBunny.mp4'. The video file seems to be loading because I'm no longer getting a 404 error, but I still can't get the video to play.

Console showing correct asset loaded in Rails

Upvotes: 2

Views: 2234

Answers (1)

Jonathan Yeong
Jonathan Yeong

Reputation: 563

I fixed this by replacing the video_tag with the corresponding HTML tags. I'm going to quote directly from this answer:

<video width="600" height="400" control="controls">
    <source src="../../../public/videos/BigBuckBunny.mp4" type="video/mp4">
</video>

Except in my code that still didn't work. I ended up using this:

<video width="600" height="400" control="controls">
    <source src="../../../assets/BigBuckBunny.mp4" type="video/mp4">
</video>

Upvotes: 1

Related Questions