gpt4 book ai didi

iphone - 在iPhone SDK中的YouTube播放器中播放视频

转载 作者:行者123 更新时间:2023-12-03 06:04:19 25 4
gpt4 key购买 nike

我编写了以下代码,以便在youtube嵌入式播放器中播放视频。
它打开播放器窗口并显示视频,但不播放。

if(self.isYouTube)
{
NSString *embedHTML;
NSComparisonResult order = [[UIDevice currentDevice].systemVersion compare: @"4.3" options: NSNumericSearch];
if (order == NSOrderedSame || order == NSOrderedDescending) {

embedHTML = @"<html><head><style type=\"text/css\">body {background-color:black; color:black; margin-right:auto; margin-left:auto;}</style></head><body style=\"margin:0\"><embed id=\"yt\" src=\"%@\" airplay=\"allow\" type=\"application/x-shockwave-flash\" position=\"fixed\" allowfullscreen=\"true\" autoplay=\"1\" width=\"320.0\" height=\"460.0\"></embed></body></html>";

} else {

embedHTML = @"<html><head><style type=\"text/css\">body {background-color:black; color:black; margin-right:auto; margin-left:auto;}</style></head><body style=\"margin:0\"><embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" position=\"fixed\" allowfullscreen=\"true\" autoplay=\"1\" width=\"320.0\" height=\"460.0\"></embed></body></html>";

}


NSString *contentHtml = [NSString stringWithFormat:embedHTML,self.url];

[self.webView setBackgroundColor:[UIColor blackColor]];

[self.webView loadHTMLString:contentHtml baseURL:nil];

}
else
{
NSURL *urlForOpenFile=[NSURL URLWithString:self.url];
NSURLRequest *request=[NSURLRequest requestWithURL:urlForOpenFile];
[self.webView loadRequest:request];
}

你能告诉我,代码中有什么问题。

谢谢。

最佳答案

iOS不支持Flash,您应该使用HTML 5的新标签video来包装视频网址,如下所示:
<video src="point/to/mov"></video>

关于iphone - 在iPhone SDK中的YouTube播放器中播放视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6409236/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com