Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iPhone:youtube视频链接未打开_Iphone_Objective C_Video - Fatal编程技术网

iPhone:youtube视频链接未打开

iPhone:youtube视频链接未打开,iphone,objective-c,video,Iphone,Objective C,Video,我使用以下代码在webview中打开youtube链接 [self playVideo:@"www.youtube.com/watch?v=GcpFTAqvLYQ" frame:CGRectMake(0, 44, 1024, 700)]; - (void)playVideo:(NSString *)urlString frame:(CGRect)frame { NSString *embedHTML = @"\ <html><head>\ &l

我使用以下代码在webview中打开youtube链接

[self playVideo:@"www.youtube.com/watch?v=GcpFTAqvLYQ" frame:CGRectMake(0, 44, 1024, 700)];


- (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.view addSubview:videoView];
    [videoView release];
    NSLog(@"%@",html);
}
[自播放视频:@“www.youtube.com/watch?v=GcpFTAqvLYQ”帧:CGRectMake(0,441024700)];
-(无效)播放视频:(NSString*)URLSING帧:(CGRect)帧
{
NSString*embedHTML=@”\
\
\
身体{\
背景色:透明\
颜色:白色\
}\
\
\
\
";
NSString*html=[NSString stringWithFormat:embedHTML,urlString,frame.size.width,frame.size.height];
UIWebView*videoView=[[UIWebView alloc]initWithFrame:frame];
[videoView loadHTMLString:html baseURL:nil];
[self.view addSubview:videoView];
[视频视图发布];
NSLog(@“%@”,html);
}
有了这段代码的帮助,我可以打开其他youtube链接,但这个链接没有打开

此外,我在浏览器中使用此链接,它正在浏览器中打开

我不明白是什么问题

如果你有任何想法,那就分享吧

thanx提前…

执行以下操作:

[self playVideo:@"http://www.youtube.com/watch?v=GcpFTAqvLYQ" frame:CGRectMake(0, 44, 1024, 700)];
现在播放的视频将是:

 - (void)playVideo:(NSString *)urlString frame:(CGRect)frame
{
    NSString *embedHTML = [NSString stringWithFormat:@"\
    <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>", urlString, frame.size.width, frame.size.height];
    UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame];
    [videoView loadHTMLString:embedHTML baseURL:nil];
    [self.view addSubview:videoView];
    [videoView release];
    NSLog(@"%@",embedHTML);
}
-(void)播放视频:(NSString*)urlString帧:(CGRect)帧
{
NSString*embedHTML=[NSString stringWithFormat:@”\
\
\
身体{\
背景色:透明\
颜色:白色\
}\
\
\
\
“,urlString,frame.size.width,frame.size.height];
UIWebView*videoView=[[UIWebView alloc]initWithFrame:frame];
[videoView loadHTMLString:EmbedHtmlBaseURL:nil];
[self.view addSubview:videoView];
[视频视图发布];
NSLog(@“%@”,嵌入HTML);
}

Hi friend它可以工作,但是我的代码和你的代码有什么区别。html字符串格式不正确。说它像youtube,但不像这个youtube