Retired Document
Important: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.
MPMoviePlayerController plays movie audio but not video
Q:
I'm able to successfully play movies using MPMoviePlayerController
on iOS 3.1.3. When I run this same code on the iPad and on the iPhone with iOS 4 I can hear the movie audio, but the video is no longer displayed. What's going on?
A: Starting with iPhone iOS 3.2, calling the -play:
method still starts playback of the movie but it does not ensure that the movie is visible. In order to display a movie, you must get the new view
property from your MPMoviePlayerController
object and add that view to your view hierarchy. Here's a code snippet:
Listing 1 How to add the MPMoviePlayerController
view property to your view hierarchy to play a movie.
#import <UIKit/UIKit.h> |
#import <MediaPlayer/MediaPlayer.h> |
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; |
[[player view] setFrame:[myView bounds]]; // size to fit parent view exactly |
[myView addSubview:[player view]]; |
[player play]; |
See Important Porting Tip for Using the Media Player Framework and the
Document Revision History
Date | Notes |
---|---|
2010-07-20 | New document that describes how to play movies using MPMoviePlayerController on the iPad and on the iPhone with iOS 4 |
Copyright © 2010 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2010-07-20