电影播放器​​无法播放

时间:2014-03-17 09:36:43

标签: objective-c

我正在尝试使用本指南播放视频:http://www.techotopia.com/index.php/Video_Playback_from_within_an_iOS_7_Application

所以我有:

//movieplayer initialization
NSURL *url = [NSURL URLWithString:
              @"http://www.youtube.com/watch?v=CS-6gJkNAo4"];

self.moviePlayer =  [[MPMoviePlayerController alloc]
                 initWithContentURL:url];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayBackDidFinish:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:self.moviePlayer];

self.moviePlayer.controlStyle = MPMovieControlStyleDefault;
self.moviePlayer.shouldAutoplay = YES;
[self.movieView addSubview:self.moviePlayer.view];
 [self.moviePlayer setFullscreen:YES animated:YES];

将播放器加载到某个视图的位置。 我什么也没看到,我只收到此错误消息:

_itemFailedToPlayToEnd: {
    kind = 1;
    new = 2;
    old = 0;
}

1 个答案:

答案 0 :(得分:0)

MPMoviePlayerController无法播放Youtube视频。您必须粘贴直接链接到文件才能以这种方式播放视频。