I am playing around with HTML5 video and have the following snippet in an ERB:
<video id="movie" width="320" height="240" poster="/test.jpg" preload="none" controls="">
<source src="/test.mp4" type="video/mp4; codecs="avc1.42E01E, mp4a.40.2"">
<source src="/test.ogv" type="video/ogg; codecs="theora, vorbis"">
</video>
The mp4 video streams just fine from the server running in my development environment into the chrome. However firefox displays the video player with the poster image, but with a big X. The problem seems to be that mongrel is unsure of the mime type for the ogv extenstion and just returns text/plain as shown by curl:
$ curl -I http://0.0.0.0:3000/pr6.ogv
HTTP/1.1 200 OK
Connection: close
Date: Mon, 19 Apr 2010 12:33:50 GMT
Last-Modified: Sun, 18 Apr 2010 12:46:07 GMT
Content-Type: text/plain
Content-Length: 13652587
So where do I configure things so that the correct mime type will be returned? I have tried all sorts of creative searching for an answer, but the closest thing I can find is using Mime::Type.register however that only seems to deal with the responds_to stuff and didn't have any effect when I tried it just in case.
So computer setting? Mongrel config? Rails App Config? Not really sure where to look and non an expert in mime types. My dev environement is a Mac, Rails 2.3.5.
I had the same problem, and found the solution here: http://9elements.com/io/?p=306
I'm running rails 2.3.5, so I put the following code in config/initializers/mime_types.rb and then reset my server (I'm using WEBrick for local development)
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"
})
And now curl is showing the correct mime types for ogv files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With