Rails 3 Webrick 和加载 iPhone/iPad ( mp4 m4v ) 视频文件的问题

发布于 2024-09-30 19:33:17 字数 1470 浏览 7 评论 0原文

我正在尝试让 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽清梦 2024-10-07 19:33:17

也许将以下行添加到您的 Gemfile 中?

gem 'mime-types', :require =>; '哑剧/类型'

Maybe add the following line to your Gemfile?

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文