美文网首页
MPMoviePlayerViewController视频播放三

MPMoviePlayerViewController视频播放三

作者: Loki_ | 来源:发表于2016-10-26 14:14 被阅读79次

    1、导入MediaPlayer.framework框架

    2、播放视频

    MPMoviePlayerViewController*desViewController = [[MPMoviePlayerViewControlleralloc] initWithContentURL:[NSURLURLWithString:@视频网络地址]];

    [desViewController.moviePlayerprepareToPlay];

    [self presentMoviePlayerViewControllerAnimated:desViewController];

    [desViewController.viewsetBackgroundColor:[UIColorclearColor]];

    [desViewController.viewsetFrame:self.view.bounds];

    [[NSNotificationCenter defaultCenter] addObserver:selfselector:@selector(movieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:desViewController.moviePlayer];

    3、结束播放

    -(void)movieFinishedCallback:(NSNotification*)notify{

    //视频播放完或者在presentMoviePlayerViewControllerAnimated下的Done按钮被点击响应的通知。

    MPMoviePlayerController* theMovie = [notifyobject];

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

    [self dismissMoviePlayerViewControllerAnimated];

    }

    相关文章

      网友评论

          本文标题:MPMoviePlayerViewController视频播放三

          本文链接:https://www.haomeiwen.com/subject/jqvduttx.html