views:

520

answers:

2

Now that 4.0 is public, I can edit this question and ask it again. This code works in 3.2 and any prior versions, but in 4.0 I get an alertView saying "This movie could not be played".

ivar webView

//in viewDidLoad
self.webView =  [[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];

webView.scalesPageToFit = YES;
webView.delegate = self;

// in tableView didSelectRowAtIndexPath

// url contains a video from web 
NSURL *url = [NSURL URLWithString:@"http://www.somevalid.td/validmovie.mp4"];
[webView loadRequest:[NSURLRequest requestWithURL:url]];

In the log it says "setting movie path (null)"

A: 

What I just did:

MPMoviePlayerViewController* theMoviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL: theURL];
[self presentMoviePlayerViewControllerAnimated:theMoviePlayer];

I know it's not a UIWebView, but it's the only way I got video working in OS 4.0..

Good luck though and I hope this was of any use.

Greetings,

Lewion

Lewion
thanks for your answer as well. I got it working with my code and different server settings (correct MIME types)
hecta
+1  A: 

I just tested your code and it works fine on both simulator and on a development iPhone 3GS. Could it be something with the movie file itself (maybe too high resolution for iPhone?) or something with the server.

Try to download the NSURL to a file on your device, then use Organizer to copy it to your computer and in iTunes, copy it back and see if it plays. If not, you know that the problem lies with the movie file itself.

Krumelur
User @cduhn suggested looking in to MIME return types of the server, and that seemed to be the answer. I contacted my host to add all apple specific MIME types (3gp, m4v and mp4) and now it's working. Strange it worked in 3.0 without them.
hecta