Launch Youtube app with a video

自作多情 提交于 2019-12-10 21:10:12

问题


I have an app with a UIButton, I wish, when I click the button that the iPhone launches Youtube app with directly my video ready to start to play, I've tried this code:

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

But it launches Safari in the video page. I'm trying my app on actual device.

Thanks


回答1:


As others have mentioned, this should indeed open the YouTube App- if you're testing it on your actual device.

Be aware that if you're running it in the simulator, it will open in Safari instead, as the simulator does not have the YouTube app.




回答2:


Your code should be working fine, unless you're passing a bad YouTube link.

Make sure your URL begins with "http://www.youtube.com". That's the signifier for [UIApplication sharedApplication] to open the YouTube App.

Also check out this page about iOS URL schemes, and YouTube in particular.



来源:https://stackoverflow.com/questions/6797613/launch-youtube-app-with-a-video

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