我正在尝试让Rails(3.0.0)在html5视频块中为iPhone提供一个简单的m4v视频文件。为了理智起见,我正在使用 http://camendesign.com/code/video_for_everybody 的大块头兔子视频,我知道它已为 iphone 正确编码并且可以正常工作
当我在apache服务器上运行它时,它运行完美。但是在我的 rails 开发环境中,它只是加载了一个带有斜线的黑盒子。我的直觉告诉我这一定是某种 mime 问题。
我尝试将这些行添加到我的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>'
任何人有任何想法?
最佳答案
也许将以下行添加到您的 Gemfile 中?gem 'mime-types', :require => 'mime/types'
关于iphone - Rails 3 Webrick 的问题以及为 iPhone/iPad ( mp4 m4v ) 视频文件加载视频,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4125867/