Search code examples
iosswiftswift3

To play Youtube Video in iOS app


I want to play youtube videos in my iOS App. I searched for that but the only solution I found is to embed youtube videos in the iOS app, in which video plays in webview, so in that, we can scroll and also play other videos which are in suggestion. I don't want to play video in webview, I want to play video just like it plays in player and user cannot scroll it. Is there any solution for that in Swift and also I don't want to use libraries which are against terms and condition of Youtube


Solution

  • Here's another solution if you don't want to use the API provided by YouTube and instead continue using a UIWebView.

    YouTube has functionality to load any video in fullscreen in a webview without any of the scrolling features using a URL in the format https://www.youtube.com/embed/<videoId>.

    For example, to load Gangnam Style using this method, simply direct the UIWebView to the URL https://www.youtube.com/embed/9bZkp7q19f0.