YouTube URL Scheme tvOS

坚强是说给别人听的谎言 提交于 2019-12-04 21:19:52

问题


I am trying to open YouTube's app from my application with the URL scheme or the YouTube.com domain which opens YouTube's app directly on an iOS device.

This is the code I tried:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"youtube://results?search_query=trailer+%@",movieTitle]]];

and

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://www.youtube.com/results?search_query=trailer+%@",movieTitle]]];

But nothing seems to work. Any ideas on how to retrieve the URL scheme for YouTube's tvOS application?


回答1:


Not necessarily positing this as a “correct" answer, but I think all YouTube links, on iOS at least, are handled by http, not something like youtube://.

Source (looks to be from June 2015):

https://developer.apple.com/library/ios/featuredarticles/iPhoneURLScheme_Reference/YouTubeLinks/YouTubeLinks.html




回答2:


I also encountered some issues playing youtube videos in the youtube app but I found a workaround, I used the XCDYouTubeKit library to play the youtube video's directly in my app. It's very easy to use and works fine so far.

XCDYouTubeKit : https://github.com/0xced/XCDYouTubeKit



来源:https://stackoverflow.com/questions/34473037/youtube-url-scheme-tvos

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