I am sure I am just missing something stupid but I have been stuck on this all day. Any help would be appreciated. I was trying to embed video in an ipad app. I am using xcode 4.2.5. I am following a tutorial which I found here: embeded ipad video
I have followed the instructions exactly as far as I can tell. I have started over several times. Before I was getting a memory error but this time I am not getting any errors at all. Only no video or audio. The only part of the tutorial I did not use was the last part about the ipad rotation because I’m not worried about that.
The only part I was unable to follow exactly was putting the video in the resources folder because xcode 4.5.2 does not make one. So I put MOVIE.MOV in the same directory as my .h, .m and .xib files were automatically placed in. I have tested the video and it does work on its own.
Here is the code: any help or guidance would be appreciated. Sorry for being such a NOOB.
the header:
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
@interface ViewController : UIViewController{
}
-(IBAction) playMovie;
@end
the main:
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
-(void)playMovie
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"MOVIE" ofType:@"MOV"]];
MPMoviePlayerController *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 {
MPMoviePlayerController *moviePlayer = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
if ([moviePlayer
respondsToSelector:@selector(setFullscreen:animated:)])
{
[moviePlayer.view removeFromSuperview];
}
[moviePlayer release];
}
Thankyou very much for any help.
Some things you could check: