iPhone UIWebview video playback 4.0

南楼画角 提交于 2020-01-01 07:35:12

问题


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)"


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/3016481/iphone-uiwebview-video-playback-4-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!