我正在尝试遵循本教程link,但我遇到了问题。有人可以看看,让我知道需要改变什么。 我试图查找其他示例,但似乎没有任何工作。请告诉我需要更改的内容。
以下是错误
架构i386的未定义符号: “_OBJC_CLASS _ $ _ MPMoviePlayerController”,引自: VideoScreenViewController.o中的objc-class-ref “_MPMoviePlayerPlaybackDidFinishNotification”,引自: - VideoScreenViewController.o中的[VideoScreenViewController playVideo:] - VideoScreenViewController.o中的[VideoScreenViewController moviePlayBackDidFinish:] ld:找不到架构i386的符号 clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)
这是代码
// VideoScreenViewController.h
#import <UIKit/UIKit.h>
#import "MediaPlayer/MediaPlayer.h"
@interface VideoScreenViewController : UIViewController
@property (strong, nonatomic) MPMoviePlayerController *moviePlayer;
- (IBAction)playVideo:(id)sender;
@end
}
#import "VideoScreenViewController.h"
#import "MediaPlayer/MediaPlayer.h"
@interface VideoScreenViewController ()
@end
@implementation VideoScreenViewController
@synthesize moviePlayer;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
self.view.backgroundColor = [UIColor clearColor];
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (IBAction)playVideo:(id)sender {
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"Movie" ofType:@"MOV"]];
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];
}
- (void) moviePlayBackDidFinish:(NSNotification*)notification {
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"Movie" ofType:@"MOV"]];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
if ([player
respondsToSelector:@selector(setFullscreen:animated:)])
{
[player.view removeFromSuperview];
}
}
@end
答案 0 :(得分:6)
将MediaPlayer.framework添加到您的项目中,然后尝试..
答案 1 :(得分:0)
我今天遇到了同样的问题,我发现媒体播放器框架必须正确添加:所以首先右键点击“框架”点击“添加文件到...” 将框架定位在“developers / Platforms .... etpp”文件夹中,然后单击“为任何添加的文件夹创建文件夹引用”,最后单击“添加” - 就是这样。在此之后,错误不再出现。