This is my h5 code:
id="myVideo" src="xxxapp://***.***.xx/***/***.mp4" style="object-fit:cover;opacity:1;width:100%;height:100%;display:block;possition:absolute;" type="video/mp4"></video>
I want to load local large video, so, I use WKURLSchemeHandler.
- (void)webView:(WKWebView *)webView startURLSchemeTask:(id<WKURLSchemeTask>)urlSchemeTask {
NSURLRequest *request = [urlSchemeTask request];
NSURL *url = request.URL;
NSString *urlString = url.absoluteString;
NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"***" ofType:@"mp4"];
NSData *videoData = [NSData dataWithContentsOfFile:videoPath options:nil error:nil];
NSURLResponse *response = [[NSURLResponse alloc] initWithURL:url MIMEType:@"video/mp4" expectedContentLength:videoData.length textEncodingName:nil];
[urlSchemeTask didReceiveResponse:response];
[urlSchemeTask didReceiveData:videoData];
[urlSchemeTask didFinish];
}
but its not work, data is not nil, but video do not play. I would greatly appreciate it if someone could help me find a solution!!
ps: <video><source/></video> can make it, but we cannot use it due to some reasons.