开发者

play vidoes in youtube player in iphone sdk

开发者 https://www.devze.com 2023-03-13 22:04 出处:网络
I wrote the code as follows to play the videos in youtube开发者_Python百科 embedded player . It opens the player window and shows the vidoe , but does not play .

I wrote the code as follows to play the videos in youtube开发者_Python百科 embedded player . It opens the player window and shows the vidoe , but does not play .

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

can u tell me , what's the problem in the code.

Thanks.


iOS doesn't support flash, you should use the HTML 5's new tag video to wrap the video url like this:

<video src="point/to/mov"></video>

0

精彩评论

暂无评论...
验证码 换一张
取 消