2013-10-28 22 views
1

我正在開發一個項目,其中點擊按鈕時會播放視頻。在我使用這個按鈕動作之前,MPMoviePlayer工作正常。但實現後,視頻播放良好,但播放器不識別觸摸,它甚至不顯示播放時間。只顯示像這樣( - - )。控件在MPMoviePlayerController中不起作用

我工作的這段代碼:

-(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]; 

.... 
} 

而且它不會進入到當視頻停止播放的停止通知方法。

回答

0

試試這行代碼: -

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

雅試過了。不用找了。 –

相關問題