Using Video in iPhone OS IPHONE APPS

Recording Video

Starting in iPhone OS 3.0, you can record video, with included audio, on supported devices. To display the video recording interface, create and push a UIImagePickerController object, just as for displaying the still-camera interface.

To record video, you must first check that the camera source type (UI Image Picker Controller Source Type Camera) is available and that the movie media type(k UTType Movie) is available for the camera. Depending on the media types you assign to the media Types property, the picker can directly display the still camera or the video camera, or a selection interface that lets the user choose.

Using the UI Image Picker Controller Delegate protocol, register as a delegate of the image picker. Your delegate object receives a completed video recording by way of the image Picker Controller: did Finish Picking Media With Info: method.

On supported devices, you can also pick previously recorded videos from a user’s photo library.

Playing Video Files

iPhone OS supports the ability to play back video files directly from your application using the Media Player framework (MediaPlayer. framework). Video playback is supported in full screen mode only and can be used by game developers who want to play cut scene animations or by other developers who want to play media files. When you start a video from your application, the media player interface takes over, fading the screen to black and then fading in the video content. You can play a video with or without user controls for adjusting playback; enabling some or all of these controls gives the user the ability to change the volume, change the playback point, or start and stop the video. If you disable all of these controls, the video plays until completion.

Media player interface with transport controls

Media player interface with transport controls

To initiate video playback, you must know the URL of the file you want to play. For files your application provides, this would typically be a pointer to a file in your application’s bundle; however, it can also be a pointer to a file on a remote server. You use this URL to instantiate a new instance of the MP Movie Player Controller class. This class presides over the playback of your video file and manages user interactions, such user taps in the transport controls (if shown). To initiate playback, simply call the play method of the controller.

Listing shows a sample method that plays back the video at the specified URL. The play method is an asynchronous call that returns control to the caller while the movie plays. The movie controller loads the movie in a full-screen view, and animates the movie into place on top of the application’s existing content. When playback is finished, the movie controller sends a notification to the object, which releases the movie controller now that it is no longer needed.

Playing full-screen movies

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status