支付视频时的混蛋 - MPMoviePlayerController

时间:2011-07-25 08:51:31

标签: iphone objective-c mpmovieplayercontroller mpmovieplayer

我已经使用MPMoviePlayerController对象在我的应用中播放电影但是只要我在一个函数中调用[moviePlayer play]就会有一个小混蛋然后电影开始播放。

修改 这是我正在使用的代码。

  NSString *urlStr = [[NSBundle mainBundle] pathForResource:sVideoName ofType:nil];
  NSURL  *movieURL = [NSURL fileURLWithPath:urlStr];
  moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
  moviePlayer.view.frame = CGRectMake(lowerScroll.frame.size.width *(((AppDelegate *)[UIApplication sharedApplication].delegate).currentPage-1), 0.0,1024.0,lowerScroll.frame.size.height);
  moviePlayer.controlStyle = MPMovieControlStyleNone;
  moviePlayer.scalingMode = MPMovieScalingModeFill;

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

 moviePlayer.view.backgroundColor = [UIColor clearColor];
 moviePlayer.view.alpha = 0;
 [lowerScroll addSubview:moviePlayer.view];
 [moviePlayer prepareToPlay];

 [self performSelector:@selector(showMovie) withObject:nil afterDelay:0.3];

 - (void)showMovie {

        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.2];

        [moviePlayer play];
        moviePlayer.view.alpha = 1;

        [UIView commitAnimations];
    }

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

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

        if (moviePlayer) {
            [moviePlayer stop];
            [moviePlayer.view removeFromSuperview];
            [moviePlayer release];  
            moviePlayer = nil;
        }
    }

任何人都可以告诉他们可能是什么原因以及如何删除那个混蛋。

提前完成。

0 个答案:

没有答案