我正在尝试遵循本教程link http://www.techotopia.com/index.php/Video_Playback_from_within_an_iOS_5_iPhone_Application,但我有问题。有人可以看一下并让我知道需要更改什么吗?
我尝试查找其他示例,但似乎没有一个有效。请让我知道需要更改哪些内容。
以下是错误
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 添加到您的项目中..然后尝试..
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)