0

我有一个现有应用程序的问题,问题是该应用程序在 UIScrollView 中的应用程序内播放 Youtube 视频,但是在我安装了新的 Xcode SDK 4.5.2 后,这些视频有一个空白的白色方块,它们不像他们那样工作习惯于点击它们时,这是我的应用程序中的代码:

- (void)playVideo:(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\" \
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 loadHTMLString:html baseURL:nil];
[self.scrollView addSubview:videoView];
[videoView release];
NSLog(@"%@",html);
}

- (void)viewDidLoad
{

[self playVideo:@"http://www.youtube.com/...." frame:CGRectMake(5, 20, 110, 110)];

[self playVideo:@"http://www.youtube.com/...." frame:CGRectMake(5, 170, 110, 110)];

[self playVideo:@"http://www.youtube.com/...." frame:CGRectMake(5, 320, 110, 110)];

[self playVideo:@"http://www.youtube.com/...." frame:CGRectMake(5, 470, 110, 110)];

[self playVideo:@"http://www.youtube.com/...." frame:CGRectMake(5, 620, 110, 110)];

[self playVideo:@"http://www.youtube.com/...." frame:CGRectMake(5, 765, 110, 110)];


[scrollView setScrollEnabled:YES];
[scrollView setContentSize:CGSizeMake(320,1400)];

[super viewDidLoad];
}

我不知道我需要在此代码中更改什么以使它们出现并再次播放。

4

1 回答 1

0

我为我的问题找到了解决方案。我需要在代码中更改的唯一一件事是替换此代码:

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 *embedHTML = @"<body style=\"margin:0\"> <iframe height=\"110\" width=\"110\"        src=\"http://www.youtube.com/embed/HERE YOU PUT THE ID OF YOUR VIDEO\"   frameborder=\"0\"/></iframe></body> ";
于 2012-11-19T15:07:20.640 回答