2011-04-28 75 views
2

我遇到了MPMovieplayerController的問題。MPMovieplayerController「完成」按鈕

mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; 

現在,當我嘗試寫​​列表中不包含「setControlStyle」!有什麼不對的嗎 ?

如果我直接寫入[mp setControlStyle:MPMovieControlStyleFullscreen];比視頻開始在全屏幕,但完成按鈕不顯示,但雅如果我點擊完成按鈕應該比它的工作正常的地方!

編輯:

- (id)initWithPath:(NSString *)moviePath 
    { 
// Initialize and create movie URL 
    if (self = [super init]) 
    { 
     movieURL = [NSURL URLWithString:moviePath];  
    [movieURL retain]; 
    } 
return self; 
} 

- (void) readyPlayer 
{ 
mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; 

[mp setControlStyle:MPMovieControlStyleFullscreen]; 
[mp setFullscreen:YES]; 

if ([mp respondsToSelector:@selector(loadState)]) 
{ 
    // Register that the load state changed (movie is ready) 
[[NSNotificationCenter defaultCenter] addObserver:self 
        selector:@selector(moviePlayerLoadStateChanged:) 
        name:MPMoviePlayerLoadStateDidChangeNotification 
        object:nil]; 
    } 

    else 

    { 
    [NSNotificationCenter defaultCenter] addObserver:self 
        selector:@selector(moviePreloadDidFinish:) 
        name:MPMoviePlayerContentPreloadDidFinishNotification 
        object:nil]; 
    } 

    // Register to receive a notification when the movie has finished playing. 
[[NSNotificationCenter defaultCenter] addObserver:self 
        selector:@selector(moviePlayBackDidFinish:) 
        name:MPMoviePlayerPlaybackDidFinishNotification 
        object:nil]; 
} 

    - (void) loadView 
    { 
    [self setView:[[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease]]; 
[[self view] setBackgroundColor:[UIColor blackColor]]; 
    } 

    - (void) moviePlayerLoadStateChanged:(NSNotification*)notification 
    { 
//[self makeButton]; 
// Unless state is unknown, start playback 
if ([mp loadState] != MPMovieLoadStateUnknown) 
    { 

    [[NSNotificationCenter defaultCenter] removeObserver:self 
             name:MPMoviePlayerLoadStateDidChangeNotification 
             object:nil]; 


    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO]; 

    // Rotate the view for landscape playback 
[[self view] setBounds:CGRectMake(0, 0, 480, 320)]; 
[[self view] setCenter:CGPointMake(160, 240)]; 
[[self view] setTransform:CGAffineTransformMakeRotation(M_PI/2)]; 

    // Set frame of movieplayer 
    [[mp view] setFrame:CGRectMake(0, 0, 480, 320)]; 


// Add movie player as subview 
    [[self view] addSubview:[mp view]]; 

    // Play the movie 
    [mp play]; 
} 
} 

需要指導。

+0

對於第二個問題,您是在設備上還是在模擬器上進行測試?你如何顯示MPMoviePlayerController - 也許你可以給我們看一些代碼。 – Till 2011-04-28 11:48:17

+0

在模擬器上測試... – Maulik 2011-04-28 12:53:34

+0

檢查代碼... – Maulik 2011-04-28 13:01:36

回答

1

如有關財產被稱爲controlStyle,你可以使用mp.controlStyle=..;[mp setControlStyle:..];

對於第二個問題/問題,請參閱mpmovieplayercontroller-audio-show-done-button一個快速的解決方法解決方案。

+0

亞我嘗試了兩種方式,但mp。不在列表中顯示controlStyle ... – Maulik 2011-04-28 12:53:15

+0

[mp setControlStyle:..];不會給出任何錯誤...但完成按鈕不可見...但如果我點擊完成按鈕的地方它的作品,因爲有一個完成按鈕...... !!!!我希望你明白我想說什麼。 – Maulik 2011-04-28 13:03:40

相關問題