Воспроизведение видео с помощью UIWebview

подробноВидео.h

@interface detailVideo : UIViewController {
    IBOutlet UIWebView *webview;
    NSString *urlAddress;
}
@property(nonatomic,retain)NSString *urlAddress;

@end

detailVideo.m

- (void)viewDidLoad {

NSString *reqUrl = urlAddress;

//Create a URL object.
NSURL *url = [NSURL URLWithString:reqUrl];

//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

//Load the request in the UIWebView.
[webview loadRequest:requestObj];

//  webView.opaque = NO;

webview.delegate = self;

}

The video is working fine.But if i click the Done button,it redircts some other page which consists Replay button.I want switch back from this view?

Как мне это сделать?


person vinay    schedule 06.09.2010    source источник


Ответы (1)


Вы можете воспроизводить видео во встроенном 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];

}
person Apekshit    schedule 02.02.2011