3

在这里,我想使用 mediaplayer 框架播放 youtube 视频。为此,我遵循这个过程,1)我正在添加 mediaplayer 框架。2)我正在导入#import 头文件 3)我使用google 实现了代码

但它显示线程,

谁能告诉我如何解决这个问题。

4

2 回答 2

1

请检查一下:

http://mobile.tutsplus.com/tutorials/iphone/iphone-sdk-playing-video-with-the-mediaplayer-framework/ 以及检查这个线程: 如何使用 mpplayer 从 url 播放视频?

于 2013-03-04T07:47:33.970 回答
1

请尝试一下.. 我认为这个可能对您有所帮助。

- (IBAction)playVideo:(id)sender
{    
    NSURL *videosURL = [NSURL URLWithString:@"YourVideoURL"];
    MPMoviePlayerController *moviePlayController = [[MPMoviePlayerController alloc]initWithContentURL:videosURL];
    [self.view addSubview:moviePlayController.view];

    [moviePlayController prepareToPlay];
    moviePlayController.controlStyle = MPMovieControlStyleDefault;
    moviePlayController.shouldAutoplay = YES;
    [moviePlayController setFullscreen:YES animated:YES];
}

- (void) moviePlayBackDidFinish:(NSNotification*)notification
{

    MPMoviePlayerController *player = [notification object];

    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:MPMoviePlayerPlaybackDidFinishNotification object:player];

    if ([player respondsToSelector:@selector(setFullscreen:animated:)])
    {
        [player.view removeFromSuperview];
    }
}
于 2013-03-04T07:48:58.710 回答