相关疑难解决方法(0)

将视频嵌入到UIWebView中从应用程序的Documents文件夹加载的html文件中

我有一个名为videoplay.html以下内容的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>
Run Code Online (Sandbox Code Playgroud)

使用以下代码(Loading from application bundle)它加载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];
Run Code Online (Sandbox Code Playgroud)

使用以下代码(Loading from Document folder of application)它加载html内容但显示黑色部分而不是电影文件.

NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir =[documentPaths objectAtIndex:0]
NSString …
Run Code Online (Sandbox Code Playgroud)

iphone movie uiwebview embedded-video ipad

14
推荐指数
1
解决办法
5923
查看次数

标签 统计

embedded-video ×1

ipad ×1

iphone ×1

movie ×1

uiwebview ×1