我正在尝试让 Rails (3.0.0) 在 html5 视频块中为 iphone 提供一个简单的 m4v 视频文件。为了理智起见,我正在使用来自http://camendesign.com/code/video_for_everybody的大钱兔子视频,我知道它已为 iphone 正确编码并且可以工作
当我在 apache 服务器上运行它时,它运行完美。但是在我的 Rails 开发环境中,它只是加载了一个带有斜线的黑盒子。我的直觉告诉我这一定是某种类型的哑剧问题。
我尝试将这些行添加到我的 mime_types.rb 文件中:
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"
})
但没有运气。有些人建议将此行添加到 mime_types 文件中
MIME::Type.add(MIME::Type.from_array("video/mp4", %(m4v))
但这会导致此错误:
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>'
有人知道吗?