Ios MPMoviePlayerController-xcode找不到它并显示屏幕
我尝试使用MPMoviePlayerController来播放捆绑包中的视频,它显示“使用未声明的标识符‘MPMoviePlayerController’”。我需要导入任何库才能使用该类吗?另外,我想知道如何不全屏播放,以及如何选择播放的盒子大小 守则:Ios MPMoviePlayerController-xcode找不到它并显示屏幕,ios,objective-c,mpmovieplayercontroller,Ios,Objective C,Mpmovieplayercontroller,我尝试使用MPMoviePlayerController来播放捆绑包中的视频,它显示“使用未声明的标识符‘MPMoviePlayerController’”。我需要导入任何库才能使用该类吗?另外,我想知道如何不全屏播放,以及如何选择播放的盒子大小 守则: NSString *url = [[NSBundle mainBundle] pathForResource:@"video" ofType:@"mp4"]; MPMoviePlayerController *moviePlayer = [[M
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];
您需要导入/包含电影播放器:MediaPlayer/MediaPlayer.h 此外,必须将MediaPlayer.framework添加到XCode项目中的“Frameworks”文件夹中 不全屏播放:
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];
对不起,我是初学者,如何添加框架?谢谢。单击navigator中的项目,进入构建阶段,在“链接二进制文件与库”部分点击添加图标,搜索所需库。您也可以手动添加它,右键单击项目中的frameworks->add files并导航到该位置(其地址为/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/frameworks for me)Jus现在找到了它,它变成了一个框,但它是空的!视频无法播放。。我编辑了代码哦,电影播放器一定是个财产。现在没事了。再次感谢