回答

1

設置MPMoviePlayerMPMovieControlStyleNonecontrolStyle

moviePlayer.controlStyle = MPMovieControlStyleNone; 

但是這會隱藏視圖中的所有控件。

設置爲MPMovieControlStyleNone之後,如果要顯示播放/暫停選項並查找欄,則需要添加自定義控件。 (我以前做過,我用滑塊爲搜索欄和並把它放在一個UIToolBar與工具欄按鈕一起。按鈕是播放/暫停選項)

MPMovieControlStyle

常量描述播放控件的樣式。

枚舉{MPMovieControlStyleNone,MPMovieControlStyleEmbedded,
MPMovieControlStyleFullscreen,MPMovieControlStyleDefault = MPMovieControlStyleFullscreen}; typedef NSInteger MPMovieControlStyle;

常量

MPMovieControlStyleNone

No controls are displayed. 

Available in iOS 3.2 and later. 

Declared in MPMoviePlayerController.h. 

MPMovieControlStyleEmbedded

Controls for an embedded view are displayed. The controls include a start/pause button, a scrubber bar, and a button for toggling 

全屏和嵌入式顯示模式之間。

Available in iOS 3.2 and later. 

Declared in MPMoviePlayerController.h. 

MPMovieControlStyleFullscreen

Controls for fullscreen playback are displayed. The controls include a start/pause button, a scrubber bar, forward and reverse 

求按鈕,用於全屏之間切換和嵌入式 顯示模式,用於切換方面填充模式的按鈕,以及完成 按鈕的按鈕。點擊完成按鈕可暫停視頻並退出全屏模式 。

Available in iOS 3.2 and later. 

Declared in MPMoviePlayerController.h. 

MPMovieControlStyleDefault

Fullscreen controls are displayed by default. 

Available in iOS 3.2 and later. 

Declared in MPMoviePlayerController.h. 

參考MPMoviePlayerController

+0

感謝您的迴應,但正如您在上面提到的那樣,如果我將使用MPMovieControlStyleNone,它將隱藏所有控件,當然我不想這樣做。只是我想要隱藏音量欄(它在模擬器上顯示的一樣),你有另一種方法嗎? –

+0

@MuhannadDasoqie:我已經更新了答案,請檢查。 –

0

有沒有辦法做到這一點,除了 「黑客」 子視圖。你可以繼承MPMoviePlayerViewController並迭代子視圖。在我的應用程序之一,我用這樣的代碼來刪除諸如媒體控制的事情:

- (void)removeMediaControls 
{ 
    @try 
    { 
     // Search for the MPSwipeableView 
     for (UIView *view1 in [self.view subviews]) 
     { 
      // Check for the MPSwipeableView 
      if ([[[view1 class] description] isEqualToString:@"MPSwipableView"]) 
      { 
       // Search for the MPVideoBackgroundView 
       for (UIView *view2 in [view1 subviews]) 
       { 
        // Check for the MPVideoBackgroundView 
        if ([[[view2 class] description] isEqualToString:@"MPVideoBackgroundView"]) 
        { 
         // Search for the UIView 
         for (UIView *view3 in [view2 subviews]) 
         { 
          // Check for the MPWildcatFullScreenVideoOverlay 
          if ([[[view3 class] description] isEqualToString:@"MPWildcatFullScreenVideoOverlay"]) 
          { 
           // Search for the MPWildcatFullScreenNavigationBar 
           for (UIView *view4 in [view3 subviews]) 
           { 
            // Check for the UIImageView 
            if ([[[view4 class] description] isEqualToString:@"UIImageView"]) 
            { 
             // Remove the overlay 
             [view4 removeFromSuperview]; 
            } 
           } 
          } 
         } 
        } 
       } 
      } 
     } 
    } 
    @catch (NSException * e) 
    { 

    } 
} 

上面的代碼太舊了,它與iOS 4.3的工作。在iOS 5和iOS 6上,視圖層次結構發生了變化,因此您可能必須使用每個新的iOS版本更新您的代碼。另請參閱:MPMoviePlayerController hide volume slider

+0

thnx爲響應,關於附加鏈接,我已經嘗試過,但不幸的是它不起作用,並且Xcode顯示關於MPVolumeSlider「符號未找到」的錯誤!我會嘗試你的代碼並回來 –

+0

你必須做一些反向工程來找出iOS 5或iOS 6上的類名,:-) –

相關問題