为在YouTube应用上播放视频,我正在使用以下代码。
NSURL *instagramURL = [NSURL URLWithString:@"youtube://foo"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
NSLog(@"opening youtube app...");
NSString *stringURL = @"http://www.youtube.com/watch?v=H9VdapQyWfg";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
} else {
// open in UIWebView in WebViewViewController
WebViewViewController *secondView = [self.storyboard instantiateViewControllerWithIdentifier:@"webinterface"];
secondView.headerLabel = @"YouTube";
secondView.webPath = @"http://www.youtube.com/watch?v=H9VdapQyWfg";
[self.navigationController pushViewController:secondView animated:YES];
}
现在客户改变了想法,要求将频道放入iPhone应用程序中。
为了测试,我使用了链接http://www.youtube.com/user/richarddawkinsdotnet。
但是,当我使用这个链接时,它总是在Safari中打开,而不是Youtube应用程序中。 :(
有什么建议或想法可以通过提供的链接在Youtube应用程序中打开频道吗?