'embed을 이용한 webview-youtube 바로 연동하기'에 해당되는 글 1건

  1. 2011.08.05 [아이폰] embed을 이용한 webview-youtube 바로 연동하기
개발도구/아이폰2011.08.05 18:01
  

[아이폰] webview-youtube 바로 연동하기
 

-(IBAction)film_icon:(id)sender

{

    /*

    WebView4 *webView4 = [[WebView4 alloc] initWithNibName:@"WebView4" bundle:nil];

[self.tabBarController presentModalViewController:webView4 animated:YES];

[webView4 release];

     */

    [self embedYouTube:@"https://www.youtube.com/watch?v=........&NR=1" frame:CGRectMake(20, 20, 1, 1)];


}


-(IBAction)video_icon:(id)sender

{

    

    [self embedYouTube:@"https://www.youtube.com/watch?v=........&NR=1" frame:CGRectMake(20, 20, 1, 1)];

    

    

    /*

     WebView6 *webView6 = [[WebView6 alloc] initWithNibName:@"WebView6" bundle:nil];

     

     [self.tabBarController presentModalViewController:webView6 animated:YES];

     [webView6 release];

     */

}




// 동영상 실행.

- (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame {

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\" autoplay=\"1\" \

width=\"%0.0f\" height=\"%0.0f\"></embed>\

    </body></html>";

NSString *html = [NSString stringWithFormat:embedHTML, urlString, frame.size.width, frame.size.height];

UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame];

videoView.delegate = self;

[videoView loadHTMLString:html baseURL:nil];

[self.view addSubview:videoView];

[videoView release];

}



// 웹뷰의 유튜브 재싱 버튼 클릭.

- (UIButton *)findButtonInView:(UIView *)view {

UIButton *button = nil;

if ([view isMemberOfClass:[UIButton class]]) {

return (UIButton *)view;

}

if (view.subviews && [view.subviews count] > 0) {

for (UIView *subview in view.subviews) {

button = [self findButtonInView:subview];

if (button) return button;

}

}

return button;

}



// 웹뷰가 로드된 오토플레이 강제 처리.

- (void)webViewDidFinishLoad:(UIWebView *)_webView {

UIButton *b = [self findButtonInView:_webView];

[b sendActionsForControlEvents:UIControlEventTouchUpInside];

}

Posted by 예배하는 프로그래머