iOS Video Support – Challenges & Quirks

There are a great many good things to be said about handling video on the iOS platform: Live Streaming works remarkably well, the playback quality is excellent and the programming interface is, for the most part, easy to use. This works well if all you want to do is add a video to an article page within your app, or implement a simple video library. However, there are some annoying surprises in store when you push a little further. For example, as of iOS5, you might notice that the MPMoviePlayerController is implemented as a singleton class. So if you wanted to present two videos simultaneously, perhaps cueing between one and the other, you cannot do so directly using this class. AVFoundation’s AVPlayer offers greater low-level control over your video but this too comes at a price – attempting to seek to an accurate cue-point using streamed media won’t work. The best you’ll get is the nearest .ts file boundary. I was working on a project that involved all these classes recently and thought I had struck upon a brilliant solution to the seek accuracy problem by allowing the system to cue to the inaccurate .ts boundary and then to ‘play’ into the desired, accurate cue-point. The problem is, while playing into this cue-point, the system plays the sound whether you want it to or not – there’s no way to specifically mute streamed media delivered in this way. Interestingly, you can utilise two video streams simultaneously if you work with one in an MPMoviePlayerController and the other in an AVPlayer. This isn’t ideal, but if you absolutely must have multiple streams, that’s the way to go. AirPlay support for both AVPlayer and MPMoviePlayerController arrived with iOS5 (previously, you could not AirPlay direct from an AVPlayer object). This is great, but the API lacks the ability to target specific AirPlay-enabled devices so you must rely on the user selecting one. Again if you’re managing more than one video stream, you may have problems presenting a seamless viewing experience over AirPlay as you switch between players. One of the missed opportunities on the platform is the ability to maintain several AVPlayer and AVPlayerItem objects independently. Thinking back again to a recent project, it would have been useful to cue up a number of video assets in separate AV objects, roll into accurate cue-points on each and then play them back in response to user-generated events. From the structure of the media APIs in general, you certainly get a feel for where Apple would like to take them as many techniques, including those above, are tantalisingly close to being possible. Hopefully in an iOS version not too far in the future, the API will have these gaps filled in.

  • Dated: November 7, 2011

Respond below to “iOS Video Support – Challenges & Quirks”

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>