2

我正在尝试遵循本教程链接,但我遇到了问题。有人可以看看,让我知道需要改变什么。我试图查找其他示例,但似乎都没有。请让我知道需要更改的内容。

以下是错误

体系结构 i386 的未定义符号:“_OBJC_CLASS_$_MPMoviePlayerController”,引用自:VideoScreenViewController.o 中的 objc-class-ref “_MPMoviePlayerPlaybackDidFinishNotification”,引用自:VideoScreenViewController.o 中的 -[VideoScreenViewController playVideo:] -VideoScreenViewController 中的 [VideoScreenViewController moviePlayBackDidFinish:]。 o 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
4

2 回答 2

6

将 MediaPlayer.framework 添加到您的项目中..然后尝试..

于 2013-03-23T11:41:29.090 回答
0

我今天遇到了同样的问题,我发现必须正确添加媒体播放器框架:所以首先右键单击“框架”单击“将文件添加到..”,找到文件夹“开发人员/平台”中的框架。 ...etpp”然后单击“为任何添加的文件夹创建文件夹引用”,最后单击“添加”-就是这样。在此之后,错误不再出现。

于 2013-05-22T19:27:38.467 回答