您好我正在尝试在我的UIWebView中播放本地视频。
我不认为我这样做是对的。之前很容易,因为您可以将本地视频放入Mainbundle,只需将html标记命名为:
但现在我的视频存储在文件目录/视频文件夹/ video.MOV
中我如何得到...来源(“src:”属性,对于html5视频?
NSString *videoHtml = [NSString stringWithFormat:@"<div align=\"center\"><video src=\"%@\" controls=\"controls\"></video></div>", videoName];
[cell.videoWebView loadHTMLString:videoHtml baseURL:[NSURL URLWithString:self.documentsDirectoryPath]];
提前感谢!
答案 0 :(得分:0)
好的,你可以像这样构建网址
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *videoFilePath=[documentsDirectory stringByAppendingPathComponent:@"video folder/"];
NSString *videoHtml = [NSString stringWithFormat:@"<div align=\"center\"><video src=\"%@\" controls=\"controls\"></video></div>", videoName];
[cell.videoWebView loadHTMLString:videoHtml baseURL:[NSURL URLWithString:videoFilePat]];
答案 1 :(得分:0)
试试这个
NSString *videoPath=[[NSBundle mainBundle] pathForResource:@"video" ofType:@"mov"];
NSURLRequest *req=[NSURLRequest requestWithURL:[NSURL URLWithString:videoPath]];
[cell.videoWebView loadRequest:req];