I am trying to play a video in my ViewController. Mediaplayer.framework and all the Headers are in my Frameworks folder, including the MediaPlayer.h file. But when I put
#import "TutorialViewController.h"
#import <MediaPlayer/MediaPlayer.h>
@interface TutorialViewController ()
@end
@implementation TutorialViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
MPMoviePlayerController *player =
[[MPMoviePlayerController alloc]
initWithContentURL:[NSURL fileURLWithPath:url]];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
//---play movie---
[player play];
[super viewDidLoad];
}
- (void) movieFinishedCallback:(NSNotification*) aNotification {
MPMoviePlayerController *player = [aNotification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
// 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);
}
@end
in my .m file, I get an error stating ‘MediaPlayer/MediaPlayer.h’ file not found.
What does this mean and how can I fix this?
Removing the framework from the project and re-adding it should solve this problem. What I would recommend you do is open your project’s directory and make sure that when you adding the framework to your project you only referenced the framework and didn’t copy it. If the framework exists within your project folder then delete it, otherwise just remove it’s reference from your project.
Then navigate to:
Click the “+” under “Linked Frameworks” and from here you can re-add the reference to the framework to your project.