0

私は私のiphone5であなたのチューブビデオを再生する問題を分類するのに苦労しています...私はこれのためにこのコードを使用しています:

 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]; 

誰かがこの問題を解決するために私を助けてくれますか?あなたの助けは大歓迎です。

4

2 に答える 2

0

次のリンクをたどると、これが完了します

http://apiblog.youtube.com/2009/02/youtube-apis-iphone-cool-mobile-apps.html

http://iphoneincubator.com/blog/audio-video/how-to-play-youtube-videos-within-an-application

于 2012-04-05T06:30:28.073 に答える
0

ビデオを自動的に再生するためにWebビューデリゲートメソッドを使用していますか? はいの場合は、ビデオを自動的に再生するためのコードを削除します。HTML を確認してください。の代わりに balh を使用します。もう1つ、ブラウザのビデオURLをチェックして、ビデオが存在するかどうかを確認してくださいj

于 2012-04-09T08:12:34.647 に答える