2013-10-25 71 views
2

我想使用MPMoviePlayerController从捆绑播放视频,它说“使用未声明的标识符'MPMoviePlayerController'”。我是否需要导入任何图书馆来使用这个课程?另外,我想知道如何不全屏播放,以及如何选择播放框的大小。MPMoviePlayerController - xcode没有找到它,并屏幕

代码:

NSString *url = [[NSBundle mainBundle] pathForResource:@"video" ofType:@"mp4"]; 
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]]; 
moviePlayer.shouldAutoplay=YES; 
CGRect videoRect = CGRectMake(0, 0, 300, 250); 
moviePlayer.view.frame = videoRect; 
[self.view addSubview:moviePlayer.view]; 
[moviePlayer prepareToPlay]; 
[moviePlayer play]; 

回答

0

你需要导入/包括电影播放:MediaPlayer的/ MediaPlayer.h

此外,MediaPlayer.framework必须添加到您的 “框架” 文件夹中XCode项目。

为了不在全屏播放:

self.moviePlayer.shouldAutoplay=YES; 
CGRect videoRect = CGRectMake(0, 0, 300, 250); // define the player's dimensions in compact mode here its 300 * 250 
self.moviePlayer.view.frame = videoRect; 
[self.view addSubview:self.moviePlayer.view]; 
+0

对不起,我是初学者,我怎么可以添加一个框架?谢谢。 – user2303633

+0

单击导航器中的项目,进入构建阶段,在链接二进制文件库部分点击添加图标并搜索所需的库。您也可以手动添加它,右键单击项目中的框架 - >添加文件并导航到位置(位于/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7。 0.sdk/System/Library/Frameworks for me) – R3D3vil

+0

Jus发现它http://stackoverflow.com/questions/10546374/how-add-framework-to-project-on-xcode-4-3-2 – user2303633