I am making an app that can display a preloaded file on the ios simulator. Though the display screen shows on the simulator, I can’t see the video nor hear the sound.
Here is my code.
#import "BIDViewController.h"
@implementation BIDViewController
@synthesize moviePlayer;
-(IBAction)playMovie:(id)sender
{
NSString *url = [[NSBundle mainBundle]
pathForResource:@"SwimGood" ofType:@"m4v"];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc]
initWithContentURL:[NSURL fileURLWithPath:url]];
//Play partial screen.
player.view.frame = CGRectMake(64, 100, 200, 150);
[self.view addSubview: player.view];
[self.moviePlayer prepareToPlay];
[player play];
}
I am Using like this
and It’s working fine..so it might be a problem of file type. so try to use .mov
and Don’t forgot to import MediaPlayer/MediaPlayer.h
And Add MediaPlayer framework it not exists in your main bundle.
Best Luck…