我知道这是许多主题的一部分,但我想在资源以外的地方播放下载的电影(特别是在应用程序支持文件夹中)
我用:
NSString * html = [NSString stringWithFormat:@"<video src=\"%@.%@\">Alt Text</video>", self.file.uid, self.file.extension];
NSURL * base = [NSURL fileURLWithPath:[DocumentsModel pathToStorageDirectory]];
self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 412.0)];
[self.webView setOpaque:NO];
[self.webView loadHTMLString:html baseURL:base];
HTML的价值是
<video src="9812.mp4">Alt Text</video>
base的值是
<CFURL 0x7bd9c00 [0x2478b38]>{type = 15, string = file://localhost/Users/peterpaulis/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/C0831A31-048A-4402-9638-696CC085C17B/Library/Application%20Support/tproj/Storage/, encoding = 134217984, base = (null)}
请注意该文件位于
文件://localhost/Users/peterpaulis/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/C0831A31-048A-4402-9638-696CC085C17B/Library/Application%20Support/tproj/Storage/9812.mp4
并且没问题
但没有播放
我也试过了
<video id="player" width="480" height="320" src"..." webkit-playsinline>
self.webView.allowsInlineMediaPlayback = YES;
但结果相同,视频没有显示
答案 0 :(得分:0)