How to insert a local video file in Html for playback in UIWebView?

I can play video files in WebView, but videos play automatically without user intervention. So now I follow various approaches to achieve this.

    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];

This way I can play the video file from the Internet. But I want to play files from local memory.

Even if you try to pass the local file path variable, the video cannot play. Can someone tell me how to embed my local file in html so that I can play in web view like in internet video?

CASE 1: WebView, . CASE 2: URL - , , . , URL- -

+5
2

, UIWebView. , , HTML ( , HTML, , ), .

, .

<object width="160" height="144">
<param name="autoplay" value="false">

<embed src="sample.mov" width="160" height="144"
autoplay="false" controller="false"
</embed>

</object> 
+2

.mp4 , :

[[NSBundle mainBundle] pathForResource:@"blalba" ofType:@"mp4"];

url.

, , :

NSString *documentdir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *tileDirectory = [documentdir stringByAppendingPathComponent:@"xxxx/Tiles"];
NSLog(@"Tile Directory: %@", tileDirectory);

URL WebView. iphone default Video Player, .. ..

+1

All Articles