大佬教程收集整理的这篇文章主要介绍了iphone – 将应用程序的Documents文件夹中的UIWebView中加载的html文件嵌入视频,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<!DOCTYPE html> <html> <head> <title>title</title> </head> <body> <p> This is demo html file for playing movie file embedded. </p> <p> <video controls> <source src="myvideoname.mov"> </video> </p> </body> </html>
而使用以下代码(从应用程序包加载)它加载html内容并显示电影并能播放电影文件.
NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]; NSString *path = [[NSBundle mainBundle] pathForresource:@"videoplay" ofType:@"html"]; NSString *content = [NSString StringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil]; [self.webView loadHTMLString:content baseURL:baseURL];
使用以下代码(从应用程序的文档文件夹加载)它加载html内容,但显示黑色部分而不是电影文件.
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); NSString *documentsDir =[documentPaths objectATindex:0] NSString *pathOfHTmlFile = [documentsDir StringByAppendingPathComponent:@"videoplay.html"]; NSString *content = [NSString StringWithContentsOfFile:pathOfHTmlFile encoding:NSUTF8StringEncoding error:nil]; [self.webView loadHTMLString:content baseURL:[NSURL URLWithString:documentsDir]];
我想要我的应用程序与功能UIFileSharingEnabled,使用户可以将视频放在文档文件夹本身,所以我的视频文件将只在文档文件夹.
赏金更新
我非常研究,发现如下.但是,如果视频较大(大于100 MB),则不适用于较小的视频(约为50 MB).
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,YES); NSString *documentsDir =[documentPaths objectATindex:0]; NSString *pathOfHTmlFile = [documentsDir StringByAppendingPathComponent:@"videoplay.html"]; NSString *content = [NSString StringWithContentsOfFile:pathOfHTmlFile encoding:NSUTF8StringEncoding error:nil]; documentsDir = [documentsDir StringByreplacingoccurrencesOfString:@"/" withString:@"//"]; documentsDir = [documentsDir StringByreplacingoccurrencesOfString:@" " withString:@"%20"]; NSURL *baseURL = [NSURL URLWithString:[NSString StringWithFormat:@"file:/%@//",documentsDir]]; NSLog(@"Baseurl--->%@",baseURL); [self.webView loadHTMLString:content baseURL:baseURL];
如果你能帮助我,这个奖励点将是你的.因为我必须在我的项目中实现这一点,所以我没有别的办法.我真的很困惑plz plz plz Help
以上是大佬教程为你收集整理的iphone – 将应用程序的Documents文件夹中的UIWebView中加载的html文件嵌入视频全部内容,希望文章能够帮你解决iphone – 将应用程序的Documents文件夹中的UIWebView中加载的html文件嵌入视频所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。