tags:

views:

924

answers:

4

Hi everybody.

I make a iPhone App that display some videos, I made it with Xcode 3.2.2 with iPhone SDK 3.1.3 and works fine. But a few days ago I downloaded the last version of the iPhone SDK for iOS 4, the proyect Build ok, no erros, no warnings, but when I run the aplication the video didn't work, the image didn't load but sound works. I don't understand it.

Here is the code that I used.

NSBundle *Bundle = [NSBundle mainBundle];
NSString *moviePath = [Bundle pathForResource:@"Prueba" ofType:@"mp4"];
NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
theMovie.scalingMode = MPMovieScalingModeFill;
[theMovie play];

Some idea?

Best regards

+2  A: 

There is a new MPMoviePlayerViewController for 3.2 (ipad) and higher iOS4

More explanation in the DevForum https://devforums.apple.com/message/207339#207339

koregan
A: 

Thank you. Im trying with this code but I still having the same problem, I`m getting sound but no image.

ViewController.h

MPMoviePlayerViewController *movieplayer;

ViewController.m

movieplayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"sample" ofType:@"m4v"]]]; [self.view addSubview:movieplayer.view]; [movieplayer play];

noflipes
You should edit your question with addtional information, rather than add more answers, unless you've solved it.
Twelve47
A: 

I also tryed with this codes and I still having the same problem.

NSURL *url = [[[NSURL alloc]initFileURLWithPath:[[NSBundle mainBundle]pathForResource:@"Sample" ofType:@"m4v"]] autorelease];
MPMoviePlayerController *movieplayer = [[MPMoviePlayerController alloc]initWithContentURL:url];
movieplayer.movieControlMode = MPMovieControlModeDefault;
[movieplayer play];
movieplayer = mp;
[mp release];

and

NSBundle *Bundle = [NSBundle mainBundle];
NSString *moviePath = [Bundle pathForResource:@"Sample" ofType:@"m4v"];
NSURL* videoURL = [NSURL fileURLWithPath:moviePath];
MPMoviePlayerController  *movieplayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[movieplayer prepareToPlay];
[movieplayer play];

There are some error? I steell a novice but I spendign a lot of time with any progress.

Best regards

noflipes
+1  A: 

You need to embed the movie player's view into your own view to see the video:

UIView* myView = ...
UIView* movieView = [moviePlayer view];
[movieView setFrame:[myView bounds]]; // fit the movie to the exact bounds of myView
[myView addSubview:movieView];

newDev
This worked for me, I just set myView to be the current controllers view, or in my case I added a modal view
tigermain