MPMoviePlayerController error _itemFailedToPlayToEnd while playing youtube video iOS 7

I’ve seen this mentioned a few places around the web but have yet to find answer anywhere.

I am using ALMovieplayercontroller library. Everything works fine but when i am trying to play Youtube video it gives me error.

  • Setting snippet data for youtube upload via REST API using Swift
  • Most of videos not getting VideoUrl from YouTube
  • Knowing when a YouTube video starts playing from within a UIWebView
  • Embed Youtube videos :- with contains content from * , it is restricted from playback on certain site
  • How to play youtube video without UIWebView or detect video player when youtube video start playing using webview?
  • What is the Latest URL Scheme to open an youtube channel from iOS app
  • _itemFailedToPlayToEnd: {
    kind = 1;
    new = 2;
    old = 0;


    - (void)setContentURL:(NSURL *)contentURL {
        self.movieSourceType = MPMovieSourceTypeStreaming;
        [super setContentURL:contentURL];
        [[NSNotificationCenter defaultCenter] postNotificationName:ALMoviePlayerContentURLDidChangeNotification object:nil];
        [self play];

    Here is my code

    ALMoviePlayerControls *movieControls = [[ALMoviePlayerControls alloc] initWithMoviePlayer:self.moviePlayer style:ALMoviePlayerControlsStyleDefault];
    //[movieControls setAdjustsFullscreenImage:NO];
    [movieControls setBarColor:[UIColor colorWithRed:195/255.0 green:29/255.0 blue:29/255.0 alpha:0.5]];
    [movieControls setTimeRemainingDecrements:YES];
    //assign controls
    [self.moviePlayer setControls:movieControls];
    [self.view addSubview:self.moviePlayer.view];
    self.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
    //THEN set contentURL
    [self.moviePlayer setContentURL:[NSURL URLWithString:@""]];

    I am not able to find the solution for this.

    Please Help.

    3 Solutions Collect From Internet About “MPMoviePlayerController error _itemFailedToPlayToEnd while playing youtube video iOS 7”

    Yes after so much researching i found to the following soluction.

    MPMoviePlayerController directly will not play the youtube videos. you have to extract the video URL and set video URL to MPMoviePlayerController. after this video will be played.

    There are lots of API available that gives the extracted video URL.

    Some of them are below



    But using this API your application might be rejected. you should have to use on your risk.

    Best way to play youtube videos is the WebView.

    Ok!!! the problem is that the player doesn’t know what you are trying to play,

    1. you can try to change the name to x.mp4
    2. you can debug the project and see that the path and the file you are trying to play exists.

    If im not mistaken ALMovieplayercontroller is an extension of MPMoviePlayerController.
    So try setting the source type of the player to stream.

    moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;