控件在MPMoviePlayerController中不起作用

时间:2013-10-28 06:20:55

标签: ios objective-c mpmovieplayercontroller

我正在开展一个项目,在点击按钮时将播放视频。在使用此按钮操作之前,MPMoviePlayer工作正常。但实现之后,视频播放效果不错,但播放器无法识别触摸,甚至无法显示播放时间。只显示这样( - - )。

我正在处理这段代码:

-(void) sceneBegins:(id)sender
{
   ....
theMoviePlayer = [MPMoviePlayerController new];

    [theMoviePlayer setContentURL:movieURL];

    theMoviePlayer.controlStyle = MPMovieControlStyleEmbedded;

    theMoviePlayer.backgroundView.hidden = YES;

    [theMoviePlayer setMovieSourceType:MPMovieSourceTypeFile];

    theMoviePlayer.shouldAutoplay = YES;

    [theMoviePlayer prepareToPlay];

    [theMoviePlayer.view setFrame:View.bounds];
 [theMoviePlayer.view setUserInteractionEnabled:YES];

    theMoviePlayer.scalingMode = MPMovieScalingModeAspectFit;

 [View addSubview:theMoviePlayer.view];
 theMoviePlayer.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
  [theMoviePlayer play];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sceneChange:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification object:theMoviePlayer];

....
}

当视频停止播放时,它也不会进入停止通知方法。

1 个答案:

答案 0 :(得分:0)

尝试以下代码: -

[myButton addTarget:self action:@selector(dragEnded:withEvent: )
    forControlEvents: UIControlEventTouchUpInside |
    UIControlEventTouchUpOutside];