4

I am using youtube API to show video list and play that video. All was working fine with v2 but as now it's deprecated I have updated it with v3.

I am getting youtube play list successfully but when I play with that videoId provided in API it fails and showing me error as below.

Also it plays fine in browser safari as well as in mozila.

Video URL VideoLink

    **Error**
    Error Domain=YouTubeVideoErrorDomain Code=2 "Invalid parameters." UserInfo=0x7f877064c610 
    {NSURL=https://www.youtube.com/get_video_info?el=detailpage&hl=en&ps=default&video_id=https%3A%2F%2F
    www.youtube.com%2Fwatch%3Fv%3DRgKAFK5djSk%26feature%3Dyoutube_gdata, NSLocalizedDescription=Invalid parameters.}
Niks
  • 647
  • 5
  • 16

1 Answers1

2

My understanding of your question is that you are struggling to get the video to play in your app? And from your error output, to me anyway, it seems like you are trying to pass the URL to something native like MPMoviePlayerController?

If so, this can be done, but the way you are approaching it is wrong. What you need to do is to use a YouTube Video URL link extractor library which will use the Video ID you get back from the YouTube API V3 to then get a list of MP4 video URL's. You can then use these URL's to play the video natively.

Here is a great link extractor library that you can use: https://github.com/runmad/RMYouTubeExtractor

I should mention that this is against the YouTube ToS, so if you want to do it the way that Google permits, then you need to simply embed that video in a small UIWebView. (Which looks and works horribly). Use this library to do just that: https://github.com/youtube/youtube-ios-player-helper

  • Yes, I am using MPMoviePlayerController, I got about you told to use youtube video url extractore, But with v2 it was working without done anything like this. I mean i have to use this because of change in v3? – Niks Jun 10 '15 at 10:48
  • @Niks Yes as of YouTube API V3, the actual video file links are stored within the YouTube video data.So an extractor is needed in order to get those links. You can't just use the standard link anymore for the actual video file. –  Jun 10 '15 at 10:51