5

I'm trying to get Rails (3.0.0) to serve a simple m4v video file for iphone in a html5 video block. For sanity's sake i'm using the big buck bunny video from http://camendesign.com/code/video_for_everybody that I know is properly encoded for iphone and works

When i run this on an apache server it runs perfectly. But on my rails dev environment it just loads a black box with a slash through it. My instinct tells me it has to be some type of mime issue.

I've tried adding these lines to my mime_types.rb file:

Mime::Type.register "video/mp4", :mp4
Mime::Type.register "video/mp4", :m4v

Rack::Mime::MIME_TYPES.merge!({
  ".ogg"     => "application/ogg",
  ".ogx"     => "application/ogg",
  ".ogv"     => "video/ogg",
  ".oga"     => "audio/ogg",
  ".mp4"     => "video/mp4",
  ".m4v"     => "video/mp4",
  ".mp3"     => "audio/mpeg",
  ".m4a"     => "audio/mpeg"
})

But no luck. Some have suggested to add this line to the mime_types file too

MIME::Type.add(MIME::Type.from_array("video/mp4", %(m4v))

But that results in this error:

NameError: uninitialized constant MIME
    from (irb):4
    from /Users/theshaolinmonk/.rvm/gems/ruby-1.9.2-p0@rails3/gems/railties-3.0.0/lib/rails/commands/console.rb:44:in `start'
    from /Users/theshaolinmonk/.rvm/gems/ruby-1.9.2-p0@rails3/gems/railties-3.0.0/lib/rails/commands/console.rb:8:in `start'
    from /Users/theshaolinmonk/.rvm/gems/ruby-1.9.2-p0@rails3/gems/railties-3.0.0/lib/rails/commands.rb:23:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Anyone have any idea ?

  • One strange thing to note is that in Firefox, Chrome and Safari things work great. Even formats like ogg and webm load without a hitch. It's just the iPhone that won't load from my Rails environment running on Webrick. – mr_codemonkey Nov 08 '10 at 20:49
  • As this question is 5 years old, I wonder if you've found a solution. I'm going through the same problem – Aleksandrus Dec 07 '15 at 22:56

1 Answers1

0

Maybe add the following line to your Gemfile?

gem 'mime-types', :require => 'mime/types'

mahseh
  • 11
  • 2