I want to display video inside the UIWebview. When we click on the video it plays in device full screen.
How do we play video inside the UIWebview? Please note that these video files are hosted on youtube or on our server. they are not bundled along with app
To play video in UIWebView
use below code....
NSString *strVedio = @"<video controls> <source src=\"YourVideo.mp4\"> </video>";
NSString *path = [[NSBundle mainBundle] pathForResource:@"YourVideo" ofType:@"mp4"];
[Webview loadHTMLString:strVedio baseURL:[NSURL fileURLWithPath:path]];
UPDATE:
use this below code to display video in UIWebView
from video URL...
NSString *embedHTML = @"\
<html><head>\
<style type=\"text/css\">\
body {\
background-color: transparent;
color: white;
}\
</style>\
</head><body style=\"margin:0\">\
<embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
width=\"%0.0f\" height=\"%0.0f\"></embed>\
</body></html>";
NSString *strHtml = [NSString stringWithFormat:embedHTML, yourURLString, width,height];//set width and height which you want
[webView loadHTMLString:strHtml baseURL:nil];
[self.view addSubview:webView];
If you want to display in small screen only and without webview then use bellow code..
MPMoviePlayerController *videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
[player setControlStyle:MPMovieControlStyleNone];
player.view.frame = CGRectMake(0, 0, 150, 150);
[self.view addSubview:videoPlayer.view];