2

Question:

How do I open a YouTube URL (from my tvOS Application) to the YouTube tvOS Application?

Description:

My url fits the youtube url scheme indicated by apple. The prints I get when I run this (on the actual apple tv device) is as follows:

  1. "Can open shared application url."
  2. "tvOS 10.0 detected"
  3. "Result... false"

So for some reason it's telling me that I'm able to open the url, but then when I attempt to open it. Nothing happens (except for that last print ( see 3. above ))

    let url = URL(string: "https://www.youtube.com/watch?v=smOp5aK-_h0")
    if UIApplication.shared.canOpenURL(url){
        print("Can open shared application url.")
        if #available(tvOS 10.0, *) {
            print("tvOS 10.0 detected")

            UIApplication.shared.open(url){res in
                print("Result..." + String(res))
            }
        } else {
            // Fallback on earlier versions
            UIApplication.shared.openURL(url)
        }
    }

Youtube URL Scheme:

Native app URL strings:

http://www.youtube.com/watch?v=VIDEO_IDENTIFIER http://www.youtube.com/v/VIDEO_IDENTIFIER

kemicofa ghost
  • 14,587
  • 5
  • 63
  • 112

2 Answers2

1

Many tvOS devs would like to have an option to play YouTube content in their apps on the AppleTV, which is only possible through the YouTube app. It's up to Google to add support for URL schemes compatible with the ones available in the iOS version of the app and they don't seem motivated to make this extra effort.

  • Thanks for being willing to contribute to StackOverflow! However, your answer doesn't really contribute anything to this question. You could improve the quality of this answer by adding sources that say it doesn't work right now. Just from reading your answer, it's not easy for me to determine if it really doesn't work, or just that you don't how to make it work. – Rob Watts Feb 14 '17 at 18:45
  • I think this is the best answer one can get. It says there there is no obvious solution to this problem. With all due respect I think that only one who has a solution can improve the quality of this anwer. I have been a tvOS developer ever since the platform became available and I know there is no better answer at this time. – user2829898 Feb 15 '17 at 04:33
0

While the methods do exist to open a URL in a shared application, it does not seem to be supported (by YouTube?) as of right now.

The best I was able to do was to open YouTube Apple Tv App, but it is unable to play the video I wanted.

kemicofa ghost
  • 14,587
  • 5
  • 63
  • 112