0
내 앱에 YouTube 동영상을 통합하려고합니다. 그러나 비디오가 끝나면 viewController 호출자에게 다시보고 싶습니다. 나는 거의 구현할 수 있었지만 내 방식으로는 사용자가 완료 버튼을 누른 다음 다른 버튼을 눌러 원래 ViewController로 돌아 가야합니다.이전 ViewControlloer로 돌아가서 앱 내부에서 YouTube 동영상보기
이 코드는 제가 사용하는 코드입니다. 제발 도와주세요, 전체 코드 나 코드 예제를 참조하는 것이 더 좋습니다.
YouTubeView.h :
#import <UIKit/UIKit.h>
@interface YouTubeView : UIWebView
{
}
- (YouTubeView *)initWithStringAsURL:(NSString *)urlString frame:(CGRect)frame mimeSubType:(NSString *)mimeType;
@end
YouTubeView.m :
#import "YouTubeView.h"
@interface YouTubeView()
@end
@implementation YouTubeView
- (YouTubeView *)initWithStringAsURL:(NSString *)urlString frame:(CGRect)frame mimeSubType:(NSString *)mimeType
{
NSString *strMimeType;
if([mimeType length]>0)
{
strMimeType = mimeType;
}
else
{
strMimeType [email protected]"x-shockwave-flash"; //@"x-shockwave-mp4";
}
if (self = [super init])
{
// Create webview with requested frame size
self = [[UIWebView alloc] initWithFrame:frame];
// HTML to embed YouTube video
NSString *videoHTML = [NSString stringWithFormat:@"\
<html>\
<head>\
<style type=\"text/css\">\
iframe {position:absolute; top:50%%; margin-top:-130px;}\
body {background-color:#000; margin:0;}\
</style>\
</head>\
<body>\
<iframe width=\"100%%\" height=\"240px\" src=\"%@\" frameborder=\"0\" allowfullscreen></iframe>\
</body>\
</html>", urlString];
[self loadHTMLString:videoHTML baseURL:nil];
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
@end
하고 * 주의 ViewController상의 점 버튼 : - (IBAction를) runTestVideo (ID)를 송신기 {
NSString *strNormalVdoURL = [NSString stringWithFormat:@"http://www.youtube.com/embed/TgLqH9n57B0"];
YouTubeView *videoVw = [[YouTubeView alloc] initWithStringAsURL:[NSString stringWithFormat:@"%@",strNormalVdoURL] frame:CGRectMake(0,0,315,420) mimeSubType:@"x-shockwave-flash"];
[self.view addSubview:videoVw];
[videoVw release];
videoVw = nil;
}
도와주세요.
사용자가 완료 버튼을 누를 필요가 없도록 할 수 있습니까? 영화가 끝나면 버튼처럼 끝날 것입니다. – Idan