iPhone SDK- Launch youtube application from within my application

泄露秘密 提交于 2019-12-06 11:38:56

I've created a test project with following code executed:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=5ra01Bqef7A"]];

Running the project in Simulator allowed to reproduced the issue you've stumbled upon: test app launched Safari and it simply opened the Youtube video's page. But when I ran the same project on an iPhone the result was different: it launched the Youtube app and it started lading/playing the video in the URL right away.

The reason why the same code behaves itself differently is that there's no Youtube app in Simulator, so the only URL handler available in its environment is Safari. So everything's working as it should, you can continue developing your app.

BTW here's a really nice official blog post from Youtube about integrating it with iPhone apps: YouTube APIs + iPhone = Cool mobile apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!