我想要在iPhone應用程序中播放基本電影;然而,我似乎無法讓它工作。這裏是我的全部代碼:爲什麼我的電影不能使用MPMoviePlayerController播放?
#import <MediaPlayer/MediaPlayer.h>
#import "ViewController.h"
@implementation ViewController
- (IBAction)playMoviePressed:(id)sender
{
NSURL *url = [NSURL URLWithString:@"http://www.ebookfrenzy.com/ios_book/movie/movie.mov"];
MPMoviePlayerController *moviePlayer =
[[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
[moviePlayer prepareToPlay];
[moviePlayer play];
}
@end
我在屏幕上一個按鈕,當被竊聽調用playMoviePressed
。我知道這個方法正在被調用。我也試過用.mov
和.mp4
這個本地文件,我把它拖入xcode。