Chapter 28. Playing Video in Your Application
In This Chapter
Playing video bundled in your application |
Learning how to play cut scenes using MPEG video |
Streaming video from the Internet |
You've seen how to play audio in your applications. You've also seen how to play items from a user's iPod library, and how to control the iPod application from your application. The Media Player framework has one more goodie for you to investigate, and this is the MPMoviePlayerController
, which enables you to play movies within your applications.
The MPMoviePlayerController
is capable of playing H.264 video at 640×480 resolution at 30 frames per second. It can play media contained within your application bundle, or it can stream video over the Internet from a URL. When the player begins playing, it fades out your user interface (UI) and fades in the media player. When the video has finished, it fades out the media player and brings back your UI. It is only capable of displaying video full screen; it is not able to display it in a portion of the screen.
Let's take a look at how to utilize this class to play video within your application.
Playing Video Files Contained in the App Bundle
Playing videos from inside your application bundle using the MPMoviePlayerController
is a snap. Naturally, you have to be sure that the media is included in your application, so it has to be bundled as a resource. Then you simply use the NSBundle
method pathForResource:ofType:
to get the path to the movie within your application's ...
Get Cocoa Touch™ for iPhone® OS 3 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.