iPhone UIWebview视频播放4.0

时间:2010-06-10 16:43:17

标签: iphone uitableview uiwebview ios4

现在4.0是公开的,我可以编辑这个问题并再次询问。 此代码适用于3.2和任何以前的版本,但在4.0中我得到一个alertView说“这部电影无法播放”。

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]];

在日志中显示“设置电影路径(null)”

2 个答案:

答案 0 :(得分:1)

我刚刚做了什么:

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

我知道它不是UIWebView,但这是我在OS 4.0中使用视频的唯一方式..

祝你好运,我希望这有用。

问候,

Lewion

答案 1 :(得分:1)

我刚测试了你的代码,它在模拟器和开发iPhone 3GS上运行良好。它可能是电影文件本身的东西(可能是iPhone的分辨率太高了?)或服务器的东西。

尝试将NSURL下载到设备上的文件中,然后使用管理器将其复制到计算机和iTunes中,将其复制回来查看是否播放。如果没有,你知道问题在于电影文件本身。

相关问题