zoukankan      html  css  js  c++  java
  • MPMoviePlayerController播放视频

      MPMoviePlayerController* moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:ddi.videoFileUrl];

            

            [[NSNotificationCenter defaultCenter] addObserver:self

                                                     selector:@selector(moviePlayBackDidFinish:)

                                                         name: MPMoviePlayerPlaybackDidFinishNotification

                                                       object:moviePlayer];

            [[NSNotificationCenter defaultCenter] addObserver:self

                                                     selector:@selector(moviePlayBackDidFinish:)

                                                         name:MPMoviePlayerWillExitFullscreenNotification

                                                       object:moviePlayer];

            

            moviePlayer.controlStyle = MPMovieControlStyleEmbedded;

            moviePlayer.movieSourceType=MPMovieSourceTypeFile;//这句重要,没有这句视频一片漆黑,无法播放(本地视频)MPMovieSourceTypeStreaming(网路视频)

            moviePlayer.shouldAutoplay = YES;

            [self.view addSubview:moviePlayer.view];

            [moviePlayer setFullscreen:YES animated:YES];

     

    #pragma mark - NSNotificationCenter

    -(void)moviePlayBackDidFinish:(NSNotification*)notification

    {

        MPMoviePlayerController *moviePlayer = [notification object];

        [[NSNotificationCenter defaultCenter] removeObserver:self

                                                        name:MPMoviePlayerPlaybackDidFinishNotification

                                                      object:moviePlayer];

        [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerWillExitFullscreenNotification object:moviePlayer];

        

        // If the moviePlayer.view was added to the view, it needs to be removed

        if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {

            [moviePlayer.view removeFromSuperview];

        }

        

    //    [moviePlayer release];

    }

     

  • 相关阅读:
    Runoob-JSP:JSP 表单处理
    Runoob-JSP:JSP 状态码
    Runoob-JSP:JSP 服务器响应
    extundelete
    Java实现 洛谷 P1601 A+B Problem(高精)
    Java实现 洛谷 P1601 A+B Problem(高精)
    Java实现 洛谷 P1601 A+B Problem(高精)
    Java实现 洛谷 P1508 Likecloud-吃、吃、吃
    Java实现 洛谷 P1508 Likecloud-吃、吃、吃
    Java实现 洛谷 P1508 Likecloud-吃、吃、吃
  • 原文地址:https://www.cnblogs.com/YuFly-lyx/p/5777157.html
Copyright © 2011-2022 走看看