Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
374 views
in Technique[技术] by (71.8m points)

iphone - UIWebView to Play Local and downloaded Video

I want to play downloaded video using UIWebview. I get webkiterrordomain code=204 error. but if i play video from resources folder it run perfect. //from resources folder run perfect

NSString *tempurl = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"video.mp4"];
   //from downloaded file
 NSString *tempurl = downloaded path;
NSURL* urlLocation = [NSURL fileURLWithPath:tempurl];
[webView loadRequest:[NSURLRequest requestWithURL:urlLocation]];

Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Solution is here, you can play video in Embedded UIWebView.

- (void)viewDidLoad {

[super viewDidLoad];

NSString *embedHTML = @"
<html><head>
<style type="text/css">
body {
background-color: transparent;
color: white;
}
</style>
</head><body style="margin:0">
<embed id="yt" src="http://www.businessfactors.de/bfcms/images/stories/videos/defaultscreenvideos.mp4" type="application/x-shockwave-mp4" 
width="%0.0f" height="%0.0f"></embed>
</body></html>";

webView = [[UIWebView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 412.0)];

[webView setOpaque:NO];
NSString *html = [NSString stringWithFormat:embedHTML, webView.frame.size.width, webView.frame.size.height];
[webView loadHTMLString:html baseURL:nil];

[self.view addSubview:webView];

}


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...