我正在尝试按照本教程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
最佳答案
将MediaPlayer.framework添加到您的项目中。然后尝试。