Rails 3 Webrick 和加载 iPhone/iPad ( mp4 m4v ) 视频文件的问题
我正在尝试让 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>'
有人有任何想法吗?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许将以下行添加到您的 Gemfile 中?
gem 'mime-types', :require =>; '哑剧/类型'
Maybe add the following line to your Gemfile?
gem 'mime-types', :require => 'mime/types'