Orson:
MPMoviePlayerViewController for video,
UITabBarControllerDelegate for audio

The MPMoviePlayerController we saw here was not a view (although it did have a view property), and, despite its name, it was not a view controller either. Nevertheless, a special type of view controller called a MPMoviePlayerViewController can be placed immediately above it. The following app consists of a UITabBarController with a row of five view controllers under it. One of the five view controllers is an MPMoviePlayerViewController.

The tabBarController:didSelectViewController: method of the UITabBarControllerDelegate is called automatically when the user presses a tab. This method has to reassign the MPMoviePlayerController’s URL and prepare the player to play again. (I therefore saved and restored the currentPlaybackTime.) Without these actions, the video would play only the first time the tab was pressed. The second time, it would say “Loading…” forever.

The fourth view controller (“Theme”) has no view at all. Its view property is nil. But tabBarController:didSelectViewController: plays and pauses an AVAudioPlayer (as in Gone) when we visit its tab. An AVAudioPlayer, unlike an MPMoviePlayerController, has no controls of its own and the window remains solid black. If we want controls (stop, volume, etc.), we would have to implement them ourselves.

Still to do: text view and web view should not overlap status bar. Does video play second time? Still photo should be top-justified in landscape orientation.

Source code in Orson.zip

  1. main.m
  2. Class OrsonAppDelegate is also the UITabBarControllerDelegate.
  3. Class TextViewController reads a text file containing prose by Graham Greene. Its view is a UITextView.
  4. Class StillViewController displays a production still. Its view is a UIImageView.
  5. Class ThemeViewController plays the Third Man theme by Anton Karas. It has no view.
  6. Class WebViewController displays the Wikipedia article for the movie. Its view is a UIWebView.
  7. Media files:
    1. cotton.png (415 × 304)
    2. cuckoo.mov
    3. theme.mp3 (The Third Man Theme) by Anton Karas
  8. Tab icons:
    1. Text.png
    2. Still.png
    3. Video.png
    4. Postericon.png (used for the UIWebView)
    5. Theme.png

Things to try

  1. Instead of downloading the Wikipedia article from the “mobile” website http://en.m.wikipedia.org/wiki/The_Third_Man, send a User-Agent request header. See this example.