Play embedded video in UIWebView with HTML5

前端 未结 2 478
死守一世寂寞
死守一世寂寞 2020-12-22 12:31

I\'m actually trying to play a local video into an UIWebView, with HTLM5.

What I do actually is this :

NSString *embedHTML = [NSString stringWithFo         


        
相关标签:
2条回答
  • 2020-12-22 12:41

    just change base url as

    NSString *videoPath =[[NSBundle mainBundle] pathForResource:@"xxx" ofType:@"mov"];
    
    NSString *htmlString=[NSString stringWithFormat:@"<body> <video src=\"%@\" controls autoplay height=\"400\" width=\"300\" > </video> </body>", videoPath];
    
    NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
    [xwebview loadHTMLString:htmlString baseURL:baseURL];
    
    0 讨论(0)
  • 2020-12-22 12:52

    Use this:

    NSString *embedHTML = [NSString stringWithFormat:@"<html><style></style></head><body><video src=\"%@ controls autoplay height=\"400 width=\"320></video><ul></body></html>",  [[NSBundle mainBundle] pathForResource:@"ash(1)" ofType:@"mov"]];
    
    [webView setOpaque:NO];
    //NSString *html = [NSString stringWithFormat:embedHTML, webView.frame.size.width,  webView.frame.size.height];
     NSURL *url = [NSURL URLWithString:[[NSBundle mainBundle] pathForResource:@"ash(1)" ofType:@"mov"]];
    [webView loadHTMLString:embedHTML baseURL:url];
    

    Refer more this to how to play video using html5

    0 讨论(0)
提交回复
热议问题