如何在iOS5中播放嵌入式管视频

时间:2012-04-05 06:26:21

标签: iphone objective-c ios4 ios5 sdk

我很难解决在iphone 5上播放管视频的问题... 我正在使用此代码:

 urls = [urls stringByAppendingString:@"&autoplay=1"];
 NSString *htmlString =[NSString stringWithFormat: @"<html><head> <meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 212\"/></head> <body style=\"background:#F00;margin-top:0px;margin-left:0px\"><div><object width=\"212\" height=\"212\"><param name=\"movie\" value=\"%@\">",urls];

NSString *htm2=[NSString stringWithFormat:@"</param><param name=\"wmode\" value=\"transparent\"></param>    <embed src=\"%@\"type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"212\" height=\"212\"></embed>    </object></div></body></html>",urls];
//    NSString* embedHTML = @"<html><head> </head><body style=\"margin:0\"> <iframe title=\"YouTube video player\" class=\"youtube-player\" type=\"text/html\" width=\"%d\" height=\"%d\" src=\"%@\" frameborder=\"0\" allowFullScreen></iframe> </body></html>";  

NSString* html = [NSString stringWithFormat:@"%@%@",htmlString,htm2];
NSLog(@"Html - %@",urls);
float version = [[[UIDevice currentDevice] systemVersion] floatValue];


if(version <= 5.0)
{ 

    NSRange r=[urls rangeOfString:@"v="];
    NSRange ran=NSMakeRange(r.location+2, [urls length]-r.location-2);
    NSString *vid=[urls substringWithRange:ran];
    html=[NSString stringWithFormat:@"<embed id=\"yt\" src=\"http://www.youtube.com/watch?v=%@&fs=0\" type=\"application/x-shockwave-flash\" width=\"300\" height=\"300\"></embed>", vid];
}
//NSLog(html);

[videoView loadHTMLString:html baseURL:nil]; 

有人可以帮助我解决这个问题吗? 我们将非常感谢您的帮助。

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

您是否自动使用网页视图委托方式播放视频?如果是,则删除自动播放视频的代码。检查您的HTML。用balh代替。还有一件事请检查浏览器上的视频网址确认视频是否存在j