Code, Code, Revolution!
Having problems getting your video to play on your iOS device even tough it plays back perfectly in your browser? First of all, make sure your video is in a supported format (H.264+AAC+MP4). Videos can easily be encoded using an application such as Handbreak. Make sure your HTML code is correct. Here’s a great resource on how to do video in HTML5.
Next, iOS devices only support video streaming, it will not download the entire video an play it. If your video is not playing on your iOS device there’s a good chance that the web server you are using doesn’t support byte-ranges. Byte-ranges requests are used to stream content over http and basically means that the client will ask the server for a range of bytes instead of an entire file. You find the specification for the byte-ranges header field in this RFC. If your web server doesn’t support this you will get a black box on your iOS device where the movie should otherwise appear.
Most production web servers does support byte-ranges but I ran into this problem when using a simple Ruby web server (Thin) for development. The solution was to use Thin together with Rack, which does support byte-ranges if you pull the code from GitHub and compile yourself. As of right now the Rack gem is lacking byte-ranges support.
This is also likely to happen if you have some kind of custom file handler in your web application. For example, IIS support byte-ranges, but if you are running SharePoint and want to stream a video from a document library, you can’t. SharePoint doesn’t support byte-ranges unless you enable disk caching for blobs. If you have a file handler in your web application you’re going to need to add byte-ranges support yourself. Have a look at the Rack source for byte-ranges for an example of how you support it.
With this blog I try to provide useful tips and solutions for programming .NET, Objective-C and more. My name is Björn Sållarp, and I love writing code.
It's now available on AppStore. It's free and open source. Read more about the app here: Swedish / English
Leave a reply