Search code examples
iosvideoyoutubempmovieplayercontroller

How to play YouTube videos using MPMoviePlayer?


How can i streaming video from youtube in my application. I have tried but not only black screen appear so help me to play video from youtube in movieplayer.

Thanks


Solution

  • I think the only official way is to make it play inside a UIWebView.

    However there is a project called XCDYouTubeKit that, I think, will do exactly what you want: https://github.com/0xced/XCDYouTubeKit

    That's allows you to make a youtube view play in a specific frame, that's maybe what your looking for.

    example of use:

    NSString *videoIdentifier = @"EdeVaT-zZt4"; // A 11 characters YouTube video identifier
    [[XCDYouTubeClient defaultClient] getVideoWithIdentifier:videoIdentifier completionHandler:^(XCDYouTubeVideo *video, NSError *error) {
        if (video)
        {
            // Do something with the `video` object
        }
        else
        {
            // Handle error
        }
    }];
    

    Documentation is available here: http://cocoadocs.org/docsets/XCDYouTubeKit/2.0.1/

    Good luck