iOS開發 播放Youtube影片

如果要在iPhone製作播放Youtube影片的功能

可以使用以下方式

利用UIWebView


UITextView *myUITextView1;

if(videoView == nil)
{
videoView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 37, 320, 260)];
}

videoView.backgroundColor = [UIColor clearColor];

videoView.opaque = NO;

[self.view addSubview:videoView];

NSString *htmlString =@"<html><head>"

"<meta name = \"viewport\" content = \"initial-scale = 1.0, user-scalable = no, width = 212\"/></head>"

"<body style=\"background:#FFFFF;margin-top:20px;margin-left:0px\">"

"<div><object width=\"320\" height=\"240\">"

"<param name=\"wmode\" value=\"transparent\"></param>"

"<embed src=\"http://www.youtube.com/v/9-cDZnLhUIc?f=user_favorites&app=youtube_gdata\""

"type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"320\" height=\"240\"></embed>"

"</object></div></body></html>";

[videoView loadHTMLString:htmlString baseURL:nil];

1 則迴響於《iOS開發 播放Youtube影片

  1. Hey there, I think your website might be having browser compatibility issues. When I look at your website in Chrome, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, great blog!

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *