开发者

Problems with Rails 3 Webrick and loading video for iPhone/iPad ( mp4 m4v ) video files

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 ?


Maybe add the following line to your Gemfile?

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜